MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / resolve_verifier

Function resolve_verifier

atomic-cli/src/commands/intent/list.rs:163–184  ·  view source on GitHub ↗

Resolve the verifying identity exactly as the verify verb does, but SOFT: a missing default (or no store) yields `Ok(None)` so the list still renders with all-`–` verifies. A `--identity ` that does not exist IS a hard error (`IdentityNotFound`), matching the verify verb.

(name: &Option<String>)

Source from the content-addressed store, hash-verified

161/// with all-`–` verifies. A `--identity <name>` that does not exist IS a hard
162/// error (`IdentityNotFound`), matching the verify verb.
163fn resolve_verifier(name: &Option<String>) -> CliResult<Option<Verifier>> {
164 let store = match IdentityStore::open_default() {
165 Ok(s) => s,
166 // No store at all ⇒ soft-fail to "no identity" (all verifies '–').
167 Err(_) => return Ok(None),
168 };
169 let identity = if let Some(name) = name {
170 // A named-but-missing identity is a hard error (parity with verify).
171 Some(
172 store
173 .load_by_name(name)
174 .map_err(|_| CliError::IdentityNotFound(name.clone()))?,
175 )
176 } else {
177 // No default resolvable ⇒ soft-fail, don't abort the list.
178 store.get_default().ok().flatten()
179 };
180 Ok(identity.map(|id| Verifier {
181 did: did_for_public_key(&id.public_key),
182 public_key: id.public_key,
183 }))
184}
185
186/// The DID-match-then-verify rule for an intent. Pure over its inputs so it can
187/// be unit-tested without a global `IdentityStore`.

Callers 1

runMethod · 0.70

Calls 4

did_for_public_keyFunction · 0.85
load_by_nameMethod · 0.80
cloneMethod · 0.45
get_defaultMethod · 0.45

Tested by

no test coverage detected