Skip to main content

Crate kernoid_client

Crate kernoid_client 

Source
Expand description

kernoid’s Rust SDK for clients. JMAP (RFC 8620) over HTTPS: the session, method calls with result references, uploads, downloads and the push stream. Typed calls for mail, files, calendars, contacts and principals are in the submodules; end-to-end encrypted mail in e2e (RFC 0006), finding a server in srv, iCalendar and vCard files in transfer. Everything is async on tokio; the terminal app and the apps share it.

Modules§

account
The account’s own everyday settings over kernoid’s API (/v1/account/…): its name, picture, the language kernoid writes to it in, and its mail settings. They take a session or an access token of kernoid’s apps with the scope urn:kernoid:data (RFC 0001) – not an app password, which gets Error::Unauthorized.
calendars
Calendars over JMAP (draft-ietf-jmap-calendars): the calendars of every account the user reaches, the instances of their events in a window of time, as JSCalendar; events made, changed and removed, and invitations answered – with sendSchedulingMessages, so participants hear of it (iTIP).
contacts
Contacts over JMAP (RFC 9610): the address books of every account the user reaches, and their cards as JSContact – read, made, changed and removed.
e2e
End-to-end encrypted mail (RFC 0006, 4–5) over kernoid’s extension https://kernoid.dev/jmap/openpgp: the account’s keys with the protected copies of their secret keys (OpenPgpKey/get), unlocked here with the recovery code and kept only in memory; the public keys of others (OpenPgpKey/lookup), looked up once per run; the summaries of encrypted emails for the list; encrypted emails downloaded, decrypted and read here – never through the server’s Email/parse –; and messages built, encrypted and signed here, imported into Drafts with their summary and submitted with an envelope, so that the server sees neither text nor attachments. The cryptography is all kernoid-e2e’s.
files
Files over JMAP (draft-ietf-jmap-filenode-19): the stores the user reaches – their own, those shared with them, the tenant’s drives –, directories and files with the rights on them, downloads, uploads, kernoid’s versions of a file (https://kernoid.dev/jmap/file-versions) and its links for people without an account (https://kernoid.dev/jmap/file-links).
mail
Mail over JMAP (RFC 8621): mailboxes, the emails of one, one email to read, keywords, moving, deleting, sending through the Drafts mailbox (RFC 8621, 7.5), and the vacation response (RFC 8621, 8). End-to-end encrypted emails are opened and sent in e2e.
oidc
Logging in with OpenID Connect, as kernoid’s own apps do (RFC 0001, 7.2; RFC 8252): the authorization code flow with PKCE in the system’s browser – where kernoid’s login page asks for the passkey, the password or a second factor –, kernoid’s built-in client of the apps (kernoid_apps_client_id in the discovery document), and the scope urn:kernoid:data, with which the access token reaches JMAP, CalDAV, CardDAV and WebDAV. offline_access gives a refresh token, so that the app stays logged in.
push
Push over EventSource (RFC 8620, 7.3): a task that listens to the stream and tells which types changed; after a break it connects again, waiting longer each time (up to a minute).
reply
Replies and forwards, as every one of kernoid’s clients writes them: Re: /Fwd: before the subject (once), the text quoted, the thread kept (In-Reply-To, References), “reply to all” without the user’s own addresses, and a forward carrying the attachments along. The words around the quote are the caller’s (Phrases).
srv
Finding the JMAP server of a domain through DNS (RFC 8620, 2.2): the SRV records _jmap._tcp.<domain>, asked of the system’s name servers (/etc/resolv.conf) over UDP – over TCP when the answer was cut. Messages are written and read by hickory-proto; no own DNS parsing.
transfer
.ics and .vcf files: events and contacts read from iCalendar and vCard and written to them – converted by calcard, the library kernoid stores them with, to the JSCalendar and JSContact objects JMAP speaks.

Structs§

Account
An account in the session (RFC 8620, 2): the user’s own, one shared with them, or a drive of their tenant.
Client
A logged-in JMAP client: the session and the credentials, sent only to the origin the session came from.
Options
How a connection is made.
Responses
The responses to one request, in order: name, arguments, call id.
Session
The session resource (RFC 8620, 2).
Upload
The answer to an upload (RFC 8620, 6.1).

Enums§

Error
What went wrong talking to the server.

Constants§

CALENDARS
CONTACTS
CORE
FILENODE
FILE_LINKS
kernoid’s extension for links to files for people without an account (FileLink/*).
FILE_VERSIONS
kernoid’s extension for the versions of a file (FileVersion/get).
MAIL
PRINCIPALS
SUBMISSION
VACATION

Functions§

encode
Percent-encodes everything but RFC 3986’s unreserved characters, for the variables of URL templates.
ids_of
#ids referring to the /ids of a query call (RFC 8620, 3.7).
is_local
Whether plain HTTP to this origin stays on this machine: loopback addresses, localhost and *.localhost.
session_url
Where to find the session for what the user gave: a server (https://host, with or without a path) or, without one, the domain of the address – https://<domain>/.well-known/jmap (RFC 8620, 2.2).
set_error
The first refused change of a */set response, as an error.
split_origin
The scheme and authority of an absolute URL (https://host:port), and the rest (path and query, at least /).

Type Aliases§

Result