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

Function encode_for_storage

atomic-canonical/src/delegation.rs:317–322  ·  view source on GitHub ↗

Render a minted certificate for the identity store, admitting the bytes it produces before handing them back. Every reader of a stored grant admits it under the profile in [`crate::jcs`] before it verifies anything: [`load_for_delegate`], and the CLI's `grant list`, `grant verify`, `grant push` and `grant revoke`. So a certificate written outside that profile is signed, stored and then skipped by

(document: &Value)

Source from the content-addressed store, hash-verified

315/// [`CanonicalError::Admission`] naming the fault when the reader would refuse
316/// the document, or [`CanonicalError::Proof`] if it does not serialize.
317pub fn encode_for_storage(document: &Value) -> Result<String> {
318 let rendered = serde_json::to_string_pretty(document)
319 .map_err(|e| CanonicalError::Proof(format!("certificate does not serialize: {e}")))?;
320 jcs::admit_document(rendered.as_bytes())?;
321 Ok(rendered)
322}
323
324/// Decode a certificate presented in a request header.
325///

Calls 3

ProofClass · 0.85
admit_documentFunction · 0.85
as_bytesMethod · 0.45