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

Function delegation_header

atomic-cli/src/commands/auth.rs:440–457  ·  view source on GitHub ↗

The encoded certificate an agent identity should present, if any. `None` for a human — they have no certificate and need none. `None` too when an agent has no usable certificate, because the resulting 401 from the server ("carries no certificate") names the problem better than anything we could raise here, and a read against a public project may not need one at all.

(store: &IdentityStore, identity: &Identity, server: &str)

Source from the content-addressed store, hash-verified

438/// could raise here, and a read against a public project may not need one at
439/// all.
440fn delegation_header(store: &IdentityStore, identity: &Identity, server: &str) -> Option<String> {
441 if !identity.identity_type.is_delegated() {
442 return None;
443 }
444
445 match crate::commands::delegation::active_for(store, identity, Some(server)) {
446 Ok(resolved) => Some(atomic_canonical::delegation::encode_for_transport(
447 &resolved.document,
448 )),
449 Err(e) => {
450 log::debug!(
451 "No usable delegation for agent '{}' against {server}: {e}",
452 identity.name
453 );
454 None
455 }
456 }
457}
458
459/// What went wrong (if anything) when checking for usable push credentials.
460///

Callers 1

attach_identityFunction · 0.85

Calls 3

active_forFunction · 0.85
encode_for_transportFunction · 0.85
is_delegatedMethod · 0.80

Tested by

no test coverage detected