bovine.parse
This module contains an experimental ActivityStreams object parser.
bovine.parse
Activity
Bases: BovineObject
Represents an activity
Source code in bovine/bovine/parse/__init__.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
accept_for_follow
async
accept_for_follow(retrieve) -> Self | None
If the activity is an Accept for a Follow request, returns said Follow request. Basic validation is run on the Accept and Follow request.
In case of not an Accept for a Follow request or it being invalid None is returned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
retrieve
|
a coroutine str -> dict that takes an object_id and resolves it to the corresponding object |
required |
Source code in bovine/bovine/parse/__init__.py
object_for_create
async
object_for_create(retrieve) -> Object | None
If activity is a create, returns the corresponding object
Source code in bovine/bovine/parse/__init__.py
undo_of_follow
async
undo_of_follow(retrieve) -> Self | None
If the activity is an Undo of a Follow request, returns said Follow request. Basic validation is run on the Undo and Follow request.
In case of not an Undo of a Follow request or it being invalid None is returned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
retrieve
|
a coroutine str -> dict that takes an object_id and resolves it to the corresponding object |
required |
Source code in bovine/bovine/parse/__init__.py
Actor
Bases: BovineObject
Parses an actor object
Source code in bovine/bovine/parse/__init__.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
cryptographic_identifiers
property
cryptographic_identifiers: List[
ReferencableCryptographicIdentifier
]
Returns the cryptographic identifiers associated with the actor
Parses both the “publicKey” field and the fields suggested in FEP-521a.
identifiers
property
Lists the identifiers of the actor.
In order for the account uri to be listed as an identifier, the coroutine validate_acct_uri needs to be run
validate_acct_uri
async
validate_acct_uri(session=None) -> bool
Checks if the acct uri defined by preferredUsername and the domain can be verified using a webfinger lookup. If yes, returns True and adds the acct uri to the identifiers of the actor.
Source code in bovine/bovine/parse/__init__.py
Object
Bases: BovineObject
Basic representation of an object
Source code in bovine/bovine/parse/__init__.py
bovine.parse.bovine_object
BovineObject
Initializes an Object to be parsed
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict
|
The data to be parsed. It is assumed that data is compacted against the about:bovine context and the parts making it up are validated. |
required |
Source code in bovine/bovine/parse/bovine_object.py
bovine.parse.types
ReferencableCryptographicIdentifier
dataclass
Bases: CryptographicIdentifier
Allows one to track further meta data associated with a CryptographicIdentifier.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str | None
|
The id of the object containing the identifier |
None
|
verification_relationships
|
Information for which use cases a cryptographic identifier is meant |
required | |
controller
|
str
|
The URI of the actor that controls the public key |
required |
public_key
|
Ed25519PublicKey | RSAPublicKey | EllipticCurvePublicKey
|
Public key used to verify signatures |
required |
Source code in bovine/bovine/parse/types.py
from_multikey
classmethod
from_multikey(clz, multikey: dict)
from_public_key
classmethod
from_public_key(clz, data: dict)
Creates a ReferencableCryptographicIdentifier from a publicKey object, example:
{
"id": "https://com.example/issuer/123#main-key",
"owner": "https://com.example/issuer/123",
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----"
}
Source code in bovine/bovine/parse/types.py
with_verification_relationships
Adds the verification relationships