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

Function resolve_verifier

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

257/// with all-`–` verifies. A `--identity <name>` that does not exist IS a hard
258/// error (`IdentityNotFound`), matching the verify verb.
259fn resolve_verifier(name: &Option<String>) -> CliResult<Option<Verifier>> {
260 let store = match IdentityStore::open_default() {
261 Ok(s) => s,
262 // No store at all ⇒ soft-fail to "no identity" (all verifies '–').
263 Err(_) => return Ok(None),
264 };
265 let identity = if let Some(name) = name {
266 // A named-but-missing identity is a hard error (parity with verify).
267 Some(
268 store
269 .load_by_name(name)
270 .map_err(|_| CliError::IdentityNotFound(name.clone()))?,
271 )
272 } else {
273 // No default resolvable ⇒ soft-fail, don't abort the list.
274 store.get_default().ok().flatten()
275 };
276 Ok(identity.map(|id| Verifier {
277 did: did_for_public_key(&id.public_key),
278 public_key: id.public_key,
279 }))
280}
281
282/// The DID-match-then-verify rule for an intent. Pure over its inputs so it can
283/// be unit-tested without a global `IdentityStore`.

Callers 1

runMethod · 0.70

Calls 5

load_by_nameMethod · 0.80
did_for_public_keyFunction · 0.50
cloneMethod · 0.45
okMethod · 0.45
get_defaultMethod · 0.45

Tested by

no test coverage detected