A DIDComm v2 attachment.
Attachments carry payloads that travel alongside a message but are not part of the message body — signed credentials, large binaries, file references, etc.
Fields
id— unique attachment identifier (within the containing message)description— human-readable descriptionfilename— suggested filename for downloaded contentmedia_type— IANA media type of the content (e.g.application/jwt)format— protocol-specific format identifier (e.g.application/vc+jwt)lastmod_time— last modification time as a Unix timestamp (integer)byte_count— size of the attached content in bytesdata— map carrying the payload; see DIDComm v2 spec §5
data map
The data map may contain one or more of:
"base64"— base64url-encoded bytes (no padding)"json"— inline JSON value"jws"— a JSON-serialized JWS (object, not a compact string)"hash"— base64url-encoded SHA-256 of the referenced content"links"— list of URLs pointing to the content
For signed credentials sent as compact JWT strings, use data.base64:
Base.url_encode64(compact_jwt, padding: false)placed under the "base64" key.
Wire format
%{
"id" => "...",
"format" => "...",
"media_type" => "...",
"data" => %{"base64" => "..."}
}Optional fields are omitted when empty/nil.
Summary
Functions
Serializes an Attachment into a DIDComm v2 JSON envelope map.
Parses a DIDComm v2 attachment map into an Attachment struct.
Types
@type t() :: %Layr8.Attachment{ byte_count: non_neg_integer() | nil, data: data_map(), description: String.t(), filename: String.t(), format: String.t(), id: String.t(), lastmod_time: non_neg_integer() | nil, media_type: String.t() }
Functions
Serializes an Attachment into a DIDComm v2 JSON envelope map.
Optional string fields are omitted when empty; optional numeric fields are
omitted when nil. data is always included (defaults to %{}).
Parses a DIDComm v2 attachment map into an Attachment struct.
Missing fields default to empty strings / nil / %{}.