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

Function resolve_verifier

atomic-cli/src/commands/memory/list.rs:207–225  ·  view source on GitHub ↗

Resolve the verifying identity exactly as `memory verify` does, but SOFT: a missing default (or no store) yields `Ok(None)` (all verifies `–`); a `--identity ` that does not exist IS a hard error.

(name: &Option<String>)

Source from the content-addressed store, hash-verified

205/// missing default (or no store) yields `Ok(None)` (all verifies `–`); a
206/// `--identity <name>` that does not exist IS a hard error.
207fn resolve_verifier(name: &Option<String>) -> CliResult<Option<Verifier>> {
208 let store = match IdentityStore::open_default() {
209 Ok(s) => s,
210 Err(_) => return Ok(None),
211 };
212 let identity = if let Some(name) = name {
213 Some(
214 store
215 .load_by_name(name)
216 .map_err(|_| CliError::IdentityNotFound(name.clone()))?,
217 )
218 } else {
219 store.get_default().ok().flatten()
220 };
221 Ok(identity.map(|id| Verifier {
222 did: did_for_public_key(&id.public_key),
223 public_key: id.public_key,
224 }))
225}
226
227/// The DID-match-then-verify rule for a memory. Pure over its inputs so it can be
228/// unit-tested without a global `IdentityStore`. See the intent list's

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