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

Function resolve_verifier

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

138/// with all-`–` verifies. A `--identity <name>` that does not exist IS a hard
139/// error (`IdentityNotFound`), matching the verify verb.
140fn resolve_verifier(name: &Option<String>) -> CliResult<Option<Verifier>> {
141 let store = match IdentityStore::open_default() {
142 Ok(s) => s,
143 // No store at all ⇒ soft-fail to "no identity" (all verifies '–').
144 Err(_) => return Ok(None),
145 };
146 let identity = if let Some(name) = name {
147 // A named-but-missing identity is a hard error (parity with verify).
148 Some(
149 store
150 .load_by_name(name)
151 .map_err(|_| CliError::IdentityNotFound(name.clone()))?,
152 )
153 } else {
154 // No default resolvable ⇒ soft-fail, don't abort the list.
155 store.get_default().ok().flatten()
156 };
157 Ok(identity.map(|id| Verifier {
158 did: did_for_public_key(&id.public_key),
159 public_key: id.public_key,
160 }))
161}
162
163/// The DID-match-then-verify rule for an intent. Pure over its inputs so it can
164/// 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