Skip to content

Class swarmauri_signing_dsse.types.DSSEEnvelope

swarmauri_signing_dsse.types.DSSEEnvelope dataclass

DSSEEnvelope(payload_type, payload_b64, signatures=tuple())

Immutable DSSE envelope compatible with the JSON wire format.

payload_type instance-attribute

payload_type

payload_b64 instance-attribute

payload_b64

signatures class-attribute instance-attribute

signatures = field(default_factory=tuple)

to_mapping

to_mapping()

Return the JSON-serializable mapping representation of the envelope.

Source code in swarmauri_signing_dsse/types.py
85
86
87
88
89
90
91
92
def to_mapping(self) -> MutableMapping[str, object]:
    """Return the JSON-serializable mapping representation of the envelope."""

    return {
        "payloadType": self.payload_type,
        "payload": self.payload_b64,
        "signatures": [sig.to_mapping() for sig in self.signatures],
    }

from_mapping classmethod

from_mapping(data)

Build a DSSE envelope from a decoded JSON mapping.

Source code in swarmauri_signing_dsse/types.py
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
@classmethod
def from_mapping(cls, data: Mapping[str, object]) -> "DSSEEnvelope":
    """Build a DSSE envelope from a decoded JSON mapping."""

    if "payloadType" not in data:
        raise ValueError("DSSE envelope mapping missing 'payloadType'")
    if "payload" not in data:
        raise ValueError("DSSE envelope mapping missing 'payload'")

    payload_type = data["payloadType"]
    payload_b64 = data["payload"]
    signatures: Iterable[Mapping[str, object]] = data.get("signatures", [])  # type: ignore[assignment]

    if not isinstance(payload_type, str) or not payload_type:
        raise ValueError("payloadType must be a non-empty string")
    if not isinstance(payload_b64, str):
        raise TypeError("payload must be a base64 string")

    if not isinstance(signatures, Iterable):
        raise TypeError("signatures must be an iterable of mappings")

    normalized_signatures = [cls._coerce_signature(sig) for sig in signatures]
    return cls(
        payload_type=payload_type,
        payload_b64=payload_b64,
        signatures=normalized_signatures,
    )

without_signatures

without_signatures()

Return a copy of the envelope without signature records.

Source code in swarmauri_signing_dsse/types.py
122
123
124
125
126
127
def without_signatures(self) -> "DSSEEnvelope":
    """Return a copy of the envelope without signature records."""

    return DSSEEnvelope(
        payload_type=self.payload_type, payload_b64=self.payload_b64, signatures=()
    )