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

Function resolve_person

atomic-cli/src/commands/provenance/command.rs:292–324  ·  view source on GitHub ↗

Resolve the PERSON's signing identity + keypair, exactly as `atomic intent attest` does.

(
    identity: Option<&str>,
)

Source from the content-addressed store, hash-verified

290/// Resolve the PERSON's signing identity + keypair, exactly as
291/// `atomic intent attest` does.
292pub(crate) fn resolve_person(
293 identity: Option<&str>,
294) -> CliResult<(
295 atomic_identity::identity::Identity,
296 atomic_identity::keypair::KeyPair,
297)> {
298 let store = IdentityStore::open_default()
299 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to open identity store: {}", e)))?;
300 let identity = if let Some(name) = identity {
301 store
302 .load_by_name(name)
303 .map_err(|_| CliError::IdentityNotFound(name.to_string()))?
304 } else {
305 store
306 .get_default()
307 .map_err(|e| {
308 CliError::Internal(anyhow::anyhow!("Failed to load default identity: {}", e))
309 })?
310 .ok_or_else(|| CliError::InvalidArgument {
311 message: "No default identity set. Create one first:\n \
312 atomic identity new <name> --email <email> --set-default"
313 .to_string(),
314 })?
315 };
316 let keypair = store.load_keypair(&identity.id, None).map_err(|e| {
317 CliError::Internal(anyhow::anyhow!(
318 "Failed to load keypair for '{}': {}",
319 identity.name,
320 e
321 ))
322 })?;
323 Ok((identity, keypair))
324}
325
326/// Print the PROV JSON-LD artifact(s) to stdout. When `signed`, add the
327/// dev-signature caveat (the signing path was used).

Callers 2

runMethod · 0.85
attest_reportFunction · 0.85

Calls 3

load_by_nameMethod · 0.80
load_keypairMethod · 0.80
get_defaultMethod · 0.45

Tested by

no test coverage detected