Expand description
JSON-LD contexts ojak does not ship, fetched to check a Linked Data Signature as Mastodon checks one.
An RsaSignature2017 signs the RDF a document means, and what it means
depends on every context it names. Mastodon turns a signed activity into
RDF with the contexts it preloads and fetches any other
(JsonLdHelper#load_jsonld_context): a GET asking for
application/ld+json, taken only when it answers 200 with that type,
read up to a megabyte, and kept in its cache for 30 days. fetch makes
that request, fetch_cached keeps what it got in a KvStore, and
resolve finds what a document is missing and adds it to a
Registry.
Nothing here runs unless an application asks: reading a document never
fetches a context (see ojak-jsonld’s contexts/README.md for why), and
the inbox fetches only to check the signature on an activity it has to
take on one, when the application has given it a loader
(Builder::remote_contexts). The fetch is the request-forgery surface
that boundary exists to avoid, so it is bounded on every side: the
guarded client refuses private addresses unless the application allows
them and follows at most its configured redirects, a context is at most
MAX_CONTEXT_BYTES, and a document may cause at most
Limits::max_remote fetches within Limits::timeout in all.
Structs§
- Limits
- Bounds on what one document may cause to be fetched.
Enums§
- Error
- Why a context could not be loaded, or a document’s contexts resolved.
Constants§
- CACHE_
TTL - How long a fetched context is kept: Mastodon’s
expires_in: 30.days. - MAX_
CONTEXT_ BYTES - The largest context taken:
Request#body_with_limit’s default. - MEDIA_
TYPE - What a context is asked for as, and the only type it is taken as.
Functions§
- fetch
- Fetch the context
irinames, asJsonLdHelper#load_jsonld_contextrequests one: a GET asking forMEDIA_TYPE, taken only when it answers200with that type, its body at mostMAX_CONTEXT_BYTESand at most the client’s own limit. What comes back is the body, which Mastodon keeps as it came. - fetch_
cached fetch, kept inkvforttl(Mastodon keeps it forCACHE_TTL) under["jsonld", "context", iri], asRails.cachekeeps it underjsonld:context:<iri>. Only a context that was taken is kept.- resolve
registrywith every contextdocumentnames that it does not hold, each loaded withload(the bodyfetchwould return): what a Linked Data Signature ondocumenthas to be checked over.Nonewhenregistryalready holds every one, so a caller keeps using the registry, and any cache, it already has.