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

Function resolve_verifier

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

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