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

Function resolve_verifier

atomic-cli/src/commands/intent/list.rs:166–187  ·  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

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