Skip to main content

Module auth

Module auth 

Source
Expand description

Enrollment (device flow), access tokens and lease renewal.

The instance’s Ed25519 key is its only long-lived secret: every access token is minted from a fresh signed assertion and cached until shortly before it expires. Nothing here runs inside a tool call.

Structs§

AppKeyOffers
The keys LeanCTX Code may hand over with a pairing: its chat key (rc4-32), its task-propose key (rc4-67) and its opt-in key (rc4-16), any of them or none (Default).
EnrollmentToken
A pre-issued Host enrollment token (het_ and 64 hex digits) that a team admin handed out, e.g. through MDM. It enrolls this machine without a browser approval. The value is wiped on drop and never printed: its Debug shows the prefix only, and no error names it.
Session
A connected instance: its record, verified lease and keys.
SetupAnnouncement
The project an engine names at connect (C0 2.1 device setup): the checkout’s folder name and the remote it sees, plus what it shares.

Enums§

ChatKeyRepair
What a chat key re-pair of a connected computer did (rc4-32, p37 §3.18.1): its reason in cloud connect --json.

Constants§

APP_KEYS_UNSUPPORTED
The words for a Cloud that cannot bind the keys of LeanCTX Code in the pairing (its code answer lacks device_app_keys, or it refused the announced app_keys): nothing was paired (app-key-bind-v1 §1).
APP_KEY_PAIRING_FAILED
The words for a pairing whose offered keys the Cloud refused as not the announced set or with a bind signature that does not verify (f3129 app_key_not_announced / app_key_bind_invalid, app-key-bind-v1 §11).
CHAT_KEY_BOUND
Another chat key is bound to this computer (409 invalid_state, reason chat_key_bound).
CHAT_KEY_CLEARED
The offered chat key was removed (409, reason chat_key_cleared).
CHAT_KEY_REFUSED
The local error for LeanCTX Cloud’s 400 invalid_field on a pairing that carried a chat key (rc4-32): the bind did not verify there.
CHAT_KEY_REPAIR_REASONS
The answers of a chat key re-pair that name why it was refused, kept by CloudError::from_response as Server { code } (this protocol version does not name them).
CHAT_KEY_TOKEN_ENROLLMENT
A computer connected with an enrollment token (400 token_enrollment).
CHAT_KEY_WITH_TOKEN
An enrollment token has no device code to sign the app keys over (f3129 S3), so it binds none: a chat key with a token is refused before anything is sent, like the task and opt-in keys.
ENROLLMENT_TOKEN_PREFIX
The plaintext prefix of a pre-issued Host enrollment token.
ENROLLMENT_TOKEN_UNUSABLE
Why a Cloud refused an enrollment token, in the words a person acts on.
OPTIN_KEY_ALREADY_BOUND
The words for a pairing while another opt-in key is bound (§46.4).
OPTIN_KEY_REFUSED
The words for a pairing whose opt-in key LeanCTX Code offered was refused (rc4-16).
OPTIN_KEY_TOKEN_ENROLLMENT
The words for a pairing with an opt-in key of a computer connected with an enrollment token (400 token_enrollment, §46.2).
OPTIN_KEY_WAS_REMOVED
The words for a pairing with an opt-in key removed on the web (§46.4).
TASK_KEY_ALREADY_BOUND
The words for a pairing while another task key is bound.
TASK_KEY_REFUSED
The words for a pairing whose task key LeanCTX Code offered was refused.
TASK_KEY_WAS_REMOVED
The words for a pairing with a task key removed on the web.

Functions§

announce_setup
Step 1b (C0 2.1): name the project and what this machine shares, so the approval page asks “Share this project” too. Only when the Cloud offers it; false when it did not take it (the terminal then asks, as before).
chat_key_repair_refusal
A refused chat key re-pair: its reason (absent for token_enrollment, for invalid_field chat_key and for an app-key refusal, whose event code is app_key_not_announced) and fixed text; None for any other error.
complete_enrollment
Verify an enrollment answer against the root key and persist it.
engine_os
enroll_with_token
Enroll this machine with a pre-issued enrollment token (no browser): one POST /v1/device/token with the token as device_code, then the enrollment is verified and persisted exactly as after a device approval.
enroll_with_token_chat
enroll_with_token as LeanCTX Code calls it: a chat key offer is refused (config) before the Cloud is contacted (CHAT_KEY_WITH_TOKEN).
finish_device_flow
Step 2: poll until the user approved (or the code expired), then verify and persist the enrollment. sleep is injectable for tests.
finish_device_flow_with
finish_device_flow that also binds the keys LeanCTX Code offers (chat key rc4-32, task-propose key rc4-67): each offer is checked against this machine’s public key before anything is sent, and its public part is kept once the pairing is accepted. A pairing without one forgets a key of that kind bound earlier.
repair_chat_key
Pair LeanCTX Code’s chat key with this ALREADY connected computer (p37 §3.18.1): the normal device flow (code from start_device_flow_for, the person approves in the browser) with the existing instance keys plus chat_key, and no replaces. LeanCTX Cloud keeps the instance, its keys, vault links and workers; locally the enrollment record, vault links and the worker state stay as they are: only the lease (and the cached session token) the answer renews and the bound chat key change.
start_device_flow
Step 1: ask Cloud for a device code; label is the user’s --label, if any (the approval page shows it, Cloud task #11).
start_device_flow_for
Step 1 for cloud connect [--trial]: trial names the plan whose one-step trial the browser starts (None: a plain sign-in, whose request is exactly the one older Clouds know).
start_device_flow_with
start_device_flow_for that announces the keys LeanCTX Code offers (f3129 S2, app-key-bind-v1 §2): app_keys in POST /v1/device/code, sorted by kind, absent when nothing is offered (the request is then byte-identical to the plain one). A Cloud whose code answer does not list device_app_keys binds no key: the pairing stops here, before the browser opens or anything is polled (fail closed, §1).
trial_refusal
A trial request an older Cloud refused for its unknown members (400 invalid_request) is CloudError::TrialUnsupported: it is never sent again without them, so nobody signs in thinking a trial started.

Type Aliases§

SharingAnswer
What the device approval answered beyond the enrollment: the page’s answer to “Share this project” (C0 2.1). None: the page did not ask (no setup, or an older Cloud); Some(None): an older page approved it.