Skip to main content

Module sites

Module sites 

Source
Expand description

Sites: the places a credential is used (roadmap R40).

A password manager keys a login to one URL. This vault keys it to an entry (a stable id and a name) and lets the entry list several places: a login page, an API address, a service on the LAN with its own port. A Site is only a normalised address. Nothing here reads a secret.

Three rules decide whether a page may be offered a credential, and each is here because a wrong answer fills a password into the wrong place:

  • The host is compared after normalisation (lower case, no trailing dot, punycode), so Example.COM. and example.com are one site and paypa1.com is not paypal.com.
  • Every loopback spelling is one host (localhost, *.localhost, 127.0.0.0/8, ::1), so a password saved for localhost:8989 also answers at 127.0.0.1:8989. The port stays significant: Sonarr and Radarr share a host and are different services.
  • A site stored without a scheme matches https, and matches http only on a private or loopback host, so a public site is never downgraded to plain text by a missing scheme.

The Rust side is the only implementation (invariant 10): the desktop reaches it over IPC and the extension host calls it directly.

Structs§

EntrySite
One address on an entry, as stored in the entry’s sites array.
Family
A named set of hosts that share a credential (for example MetaBrainz and its sister sites).
Site
A normalised address: scheme if one was given, host, port if one was given. The path, query and fragment are dropped, because a credential belongs to a service and not to a page of it.

Enums§

Mode
How strictly an origin must equal a stored site.

Constants§

KINDS
What a site is for. Free text is refused so the list stays something a UI can offer.

Functions§

add_site
Adds value (from site_value) to the entry unless the same address is already there. Returns whether it was added.
alternate_spellings
Pairs of addresses that name the same place in a different spelling: localhost:8989 and 127.0.0.1:8989, or tv.example.org and https://tv.example.org. Both are kept (a stored address is never rewritten), but a person adding the second usually did not mean to. The same text twice is not a pair, and addresses that do not parse are skipped.
builtin_families
The families that ship with the program (data/site-families.json).
entry_offered
Whether the entry may be offered at origin: one of its sites matches, or the family it names has the origin’s host. A result of true still only means “offer it”.
entry_sites
Every address an entry answers to: its sites, plus the older api_url read as one more site (a web site for a password, api for anything else), so nothing needs a migration.
families
The families kept in the vault: site_families: [{name, hosts}].
family_add
Adds hosts to the named family (creating it). Hosts are normalised to a bare host; a scheme, port or path in the input is dropped, because a family is a set of hosts.
family_has
Whether origin is a host of the family. The family host itself and its subdomains match; a look-alike (evilmusicbrainz.org) does not. A public host is matched over https only.
family_remove
Removes a host from a family, or the whole family when host is None. Returns whether anything was removed.
guess_kind
The kind a bare address most likely has: a private host is local, an api. host is api, anything else is web.
is_loopback
True for every spelling of this machine: localhost, *.localhost (RFC 6761), 127.0.0.0/8, ::1 and its IPv4-mapped form.
is_private_host
A host that is not on the public internet: loopback, RFC 1918 and link-local addresses, a single-label name, and the names a home network uses (.local, .lan, .home, .internal).
known_families
Every family an entry may name: the ones in the vault, then the shipped ones whose name the vault does not use (a family of yours with the same name replaces the shipped one).
parse_site
Normalises input: a full URL (https://sonarr.home:8989/app), an address and port (192.168.1.20:8989), or a bare host (localhost).
remove_site
Removes the site that normalises to input. Returns whether one was removed.
site_matches
Whether a page at origin may be offered a credential stored for stored.
site_value
Builds the stored form of one site. The address is normalised, so what is stored is what is matched; the path of a URL is dropped (a credential belongs to a service, not a page).