Talks to other gerbeur instances for federated sign-in: it reads their
metadata and public keys, trades a code for an identity token, delivers
events, and fetches a user's avatar. federation-service.ts,
identity-provider-service.ts and federation-peer-service.ts reach other
instances only through it.
An identity is only as safe as the connection it came over, so unlike
fetch.ts it never falls back to skipping certificate checks, and follows
no redirect. It reaches only https instances on public addresses, unless
GERBEUR_FEDERATION_ALLOW_PRIVATE lets two instances on one machine talk.
Checks that url may be reached: https on a public address, or anything
under GERBEUR_FEDERATION_ALLOW_PRIVATE.
Empties the caches, for the tests' reset between cases.
Trades code for an identity token at the token endpoint of the instance
at origin, and returns the token, unverified.
Returns the image at url, a user's avatar on their home instance, up to
the size an avatar may be.
Returns the public keys of the instance at origin, cached unless fresh
asks to refetch them and they weren't in the last minute.
Returns the metadata of the instance at origin, its issuer, cached. It
must name origin as its issuer and speak this protocol's version.
Sends the signed event event to the events endpoint of the instance at
origin, and returns whether it took it. A 4xx other than 429 means it never
will, which the caller treats as delivered.
Returns the issuer of the instance at origin, cached: origin itself, or,
when origin is where the instance's pages are and its API lives at
another, the issuer the pages' metadata names, whose own metadata must name
those pages back as where its /authorize is. People know an instance by
the address in their browser, which a sign-in form or the trust list may be
given; a handle and the stored identities name the issuer.
Usage
import * as mod from "api/remote/gerbeur-instance.ts";