Skip to content

bovine_herd.server.wellknown

wellknown = Blueprint('wellknown', __name__, url_prefix='/.well-known') module-attribute

Defines the blueprint for /.well-known

nodeinfo() async

Returns the JRD corresponding to /.well-known/nodeinfo

Source code in bovine_herd/bovine_herd/server/wellknown.py
@wellknown.get("/nodeinfo")
async def nodeinfo() -> tuple[dict, int]:
    """Returns the JRD corresponding to `/.well-known/nodeinfo`"""
    path = urlparse(path_from_request(request))
    nodeinfo = JrdLink(
        rel="http://nodeinfo.diaspora.software/ns/schema/2.0",
        href=f"{path.scheme}://{path.netloc}/activitypub/nodeinfo2_0",
    )
    application_actor = JrdLink(
        rel="https://www.w3.org/ns/activitystreams#Application",
        href=f"{path.scheme}://{path.netloc}/activitypub/bovine",
        type="application/activity+json",
    )

    return (
        pydantic_to_json(JrdData(links=[nodeinfo, application_actor])),
        200,
        {"content-type": "application/jrd+json"},
    )

webfinger() async

Returns the result for /.well-known/webfinger

Source code in bovine_herd/bovine_herd/server/wellknown.py
@wellknown.get("/webfinger")
async def webfinger() -> tuple[dict, int]:
    """Returns the result for `/.well-known/webfinger`"""
    resource = request.args.get("resource")

    if not resource:
        return {"error": "invalid request"}, 400

    if not resource.startswith("did:") and not resource.startswith("acct:"):
        return {"error": "invalid request"}, 400

    return await webfinger_response(resource)

wellknown_host_meta() async

Returns the result for /.well-known/hostmeta.

Source code in bovine_herd/bovine_herd/server/wellknown.py
@wellknown.get("/host-meta")
async def wellknown_host_meta():
    """Returns the result for `/.well-known/hostmeta`."""
    path = path_from_request(request)

    webfinger = urljoin(path, "webfinger")

    return (
        f"""<?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
  <Link rel="lrdd" template="{webfinger}?resource={{uri}}"/>
</XRD>""",
        200,
        {"content-type": "application/xrd+xml"},
    )