Skip to main content

Module mail

Module mail 

Source
Expand description

Mail to did@domain through a DHT data topic (#1117): what a mail gateway writes and what a recipient, native or in a browser, reads.

A gateway is a stateless SMTP receiver for every domain whose MX names it; its SMTP front is an application (examples/mailbox). This module is what both ends share over the DHT:

  recipient d:  μ(d) on descriptor_topic(d), every heartbeat          (registration)
  gateway:      RCPT l@any ─▶ d = addressed_did(l) ─▶ μ(d) live?       (gateway::recipient)
                DATA m ─▶ seal(m, ek(μ)) ─▶ Extend(mail_topic(d), ttl = MAX_TTL_MS)
                       ─▶ 250 at the first owner's Stored report         (gateway::deliver)
  recipient d:  fetch mail_topic(d) at start and every I ≤ H / 2 ─▶ open ─▶ file, dedup
  • address: the DID a mail address names.
  • descriptor: the signed mail descriptor μ(d), whose signature gives the key mail is sealed to.
  • registration: the heartbeat that keeps μ(d) in the DHT under the registry lease.
  • envelope: a mail as DHT elements: a manifest and its chunks (pure).
  • open: the recipient’s opening of those elements (pure).
  • gateway: the gateway’s DHT side: the RCPT lookup and the write.
  • recipient: the recipient’s poll and the records it keeps.

Storage semantics: a mail is one Extend of every element with lifetime MAX_TTL_MS, so it lives H (100 minutes) after the write and is then lost if its recipient has not fetched it. A mail is lost too when it is sealed to a delegatee key its recipient no longer holds: a browser node takes a new key at every load (recipient’s one-key law). The gateway’s 250 means that an owner reported holding the mail (#866); a read-back would be the writer’s own cache (#948, #982), not an owner’s statement. The recipient never removes: each element retires at its horizon.

Layering: application code over core’s public storage API; core knows nothing of mail.

Modules§

address
The DID a mail address names.
descriptor
The mail descriptor μ(d): a recipient’s opt-in to mail, and the key mail is sealed to.
envelope
A mail as DHT elements: a manifest and the chunks of one ciphertext (pure).
gateway
The gateway’s DHT side: whether a DID takes mail, and the write of one mail.
open
The recipient’s opening of its mail topic (pure).
recipient
The recipient’s side: its reads of its mail topic, and what it remembers. It builds for native and browser nodes alike: its records and its inbox are any key-value store (a file store natively, IndexedDB in a browser) and any MailInbox.
registration
The heartbeat that keeps a recipient’s mail descriptor in the DHT.

Functions§

mail_topic
The data topic a recipient’s mail is written to: "mail:" ‖ d.