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)
| 315 | /// [`CanonicalError::Admission`] naming the fault when the reader would refuse |
| 316 | /// the document, or [`CanonicalError::Proof`] if it does not serialize. |
| 317 | pub 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 | /// |