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

Function encode_for_transport

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

Encode a certificate for transport: JCS-canonical bytes, base64url, no pad. Canonical rather than "whatever bytes we happened to store" so the encoding is deterministic — which is what lets a server cache a verified certificate by content hash and recognise the same one next request.

(document: &Value)

Source from the content-addressed store, hash-verified

290/// is deterministic — which is what lets a server cache a verified certificate
291/// by content hash and recognise the same one next request.
292pub fn encode_for_transport(document: &Value) -> String {
293 let canonical = jcs::canonicalize(document);
294 data_encoding::BASE64URL_NOPAD.encode(canonical.as_bytes())
295}
296
297/// Decode a certificate presented in a request header.
298///

Calls 3

canonicalizeFunction · 0.85
encodeMethod · 0.45
as_bytesMethod · 0.45