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

Function resolve_verifier

atomic-cli/src/commands/memory/list.rs:133–151  ·  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

131/// missing default (or no store) yields `Ok(None)` (all verifies `–`); a
132/// `--identity <name>` that does not exist IS a hard error.
133fn resolve_verifier(name: &Option<String>) -> CliResult<Option<Verifier>> {
134 let store = match IdentityStore::open_default() {
135 Ok(s) => s,
136 Err(_) => return Ok(None),
137 };
138 let identity = if let Some(name) = name {
139 Some(
140 store
141 .load_by_name(name)
142 .map_err(|_| CliError::IdentityNotFound(name.clone()))?,
143 )
144 } else {
145 store.get_default().ok().flatten()
146 };
147 Ok(identity.map(|id| Verifier {
148 did: did_for_public_key(&id.public_key),
149 public_key: id.public_key,
150 }))
151}
152
153/// The DID-match-then-verify rule for a memory. Pure over its inputs so it can be
154/// unit-tested without a global `IdentityStore`. See the intent list's

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