Skip to main content

Module origin

Module origin 

Source
Expand description

Where an identifier’s authority comes from.

Every rule of the form “the key must belong to the actor’s server” or “an object fetched from here must say it is from here” compares origins, and an origin is one of two things:

  • for an http or https IRI, its scheme, host and port, as the web defines an origin;
  • for an ap:// IRI (FEP-ef61) or a DID URL, the DID: a portable object is vouched for by the key that controls it, wherever it is served from. So is a portable object’s compatible https identifier at a gateway, https://gateway.example/.well-known/apgateway/did:key:…/path: the gateway is where it is, not who vouches for it.

The rules are written once against Origin, never against hostnames, so that portable objects are the same rules over a second kind of origin.

Enums§

Origin
An identifier’s origin.
Port
What normalize_host does with a port.

Functions§

host_of
The host of the URL iri, without its port, in the form hosts are compared in: lower case, an internationalised name in its ASCII form, an IPv6 address in brackets. None when iri is not a URL or has no host. This is the host Mastodon’s Addressable::URI.parse(url).normalized_host reads, by which it tracks deliveries and matches domain blocks.
host_within
Whether host is parent or one of its subdomains, without regard to case: a.example.com and example.com are within example.com, and notexample.com is not. This is how a block on a domain covers its subdomains, as Mastodon’s DomainBlock.rule_for matches every suffix of a host. An empty parent has nothing within it.
normalize_host
A host as written by hand — a domain typed into a form, or taken from a handle — in the form hosts are compared in: lower case, percent-encoding decoded, an internationalised name in its ASCII form (IDNA), and a single trailing dot left off, as Addressable::URI#normalized_host has it. The port is kept or left out as port says. None when it is empty or is not a host, such as one with a space, / or @ in it.
same_authority
Whether a and b have the same authority, as a rule that only cares which server vouches for an identifier compares them: the same DID for portable identifiers, and for http and https ones the same host, whatever their schemes and ports, compared without regard to case. A portable identifier never has the authority of a web one, and an identifier that is neither has none.
same_host
Whether comparison is an http or https URL on the same host as base, whatever their schemes and ports: Mastodon’s non_matching_uri_hosts?, negated, which is how it decides that a collection page or a pinned post is on an account’s server. Hosts are compared without regard to case.
same_origin
Whether a and b have the same origin. An identifier with no origin Ojak recognises is never the same as anything.