Expand description
Shared helpers for the webvh edit-did command.
Two flows live here, both producing an UpdateDidWebvhBody
that the caller hands to either the SDK client (online) or the
local op (offline):
-
Interactive — pull the latest LogEntry’s published DID document, open it in
$EDITORviadialoguer::Editor, then walk aConfirm/Inputchain asking the operator about the webvh parameters (pre-rotation count, watcher set, TTL, audit label). -
Non-interactive — load a JSON document from a file and apply CLI flags for the parameters. Suited for scripted flows / CI / TEE-host operators.
Both flows enforce the DID-id invariant: the operator can
change everything about the document except the top-level
id field. Mutating the DID identifier mid-stream would
invalidate every existing reference to it; the WebVH spec
treats it as a permanent commitment from the first LogEntry.
Structs§
- Edit
Flags - Non-interactive flag bundle. Fed into
build_options_from_flagsto produce anUpdateDidWebvhBody. Keeping this separate fromUpdateDidWebvhBodyavoids parser/clap concerns leaking into the SDK wire type. - PreRotation
Status - Summary of the DID’s currently-effective pre-rotation setup, extracted from the on-disk log without needing to depend on didwebvh-rs. Surfaced before the “Override pre-rotation count?” prompt so the operator can see what they’re choosing to change.
Enums§
- Edit
Flow Error - Errors from the editor flow. Variant strings are operator-facing — formatted with leading lowercase so they read naturally after “Error: “ in the CLI output.
Functions§
- assert_
did_ id_ unchanged - Verify that the edited document carries the same
idas the prior version. ReturnsErr(DidIdChanged)if mutated. - build_
options_ from_ flags - Build an
UpdateDidWebvhBodyfrom the non-interactive flag bundle. The operator either runs in interactive mode (no flags → editor + prompts), supplies a--options-filefor full control (witnesses included), or uses the per-field flags below. - confirm_
publish - Final confirmation before publishing. Shows a one-line summary
of what the body actually contains; operator hits Enter (default
false) to abort. ReturnsErr(PublishCancelled)onfalse. - diff_
summary - Operator-facing summary of how many top-level fields differ between the prior and edited documents. Cheap heuristic — the CLI prints it before asking “looks good?” so the operator has a sanity check on what they touched.
- document_
id - Read the
idfield from a DID document. Used to enforce the DID-id invariant after the operator edits the document. - extract_
current_ document - Extract the published DID document from the most recent
non-empty line of a
did.jsonllog. The line is parsed as a LogEntry and itsstatefield is returned. - extract_
latest_ version_ id - Extract the
versionIdof the last non-empty log entry. Used as the optimistic-concurrency precondition on the save call: the VTA rejects the update if the DID has moved on since this versionId. ReturnsErr(EmptyLog)when the log has no entries; returnsErr(LogParse)if the latest entry is malformed or missingversionId(extremely unlikely on a valid did:webvh log — but fall back to None at the call site rather than blocking the save just because we couldn’t read a version). - extract_
pre_ rotation_ status - Walk the log latest-first to find the most recent entry that
declared
nextKeyHashes. The latest such declaration is authoritative under did:webvh delta-parameter semantics. - launch_
editor - Open
initialin$EDITOR(viadialoguer::Editor), parse the result as JSON, and verify the DIDidwasn’t mutated. ReturnsOk(None)when the operator cancels (saves an empty buffer) — the caller treats that as “abort, don’t publish.” - prompt_
webvh_ params - Walk an interactive
Confirm/Inputchain asking the operator about the webvh parameters they want to change.edited_docis the post-editor DID document (orNoneif the operator declined to edit). Returns the assembledUpdateDidWebvhBody.