Skip to content

Class swarmauri_signing_dsse.types.DSSESignatureRecord

swarmauri_signing_dsse.types.DSSESignatureRecord dataclass

DSSESignatureRecord(sig, keyid=None, cert=None)

Represent a DSSE signature record in the JSON envelope.

sig instance-attribute

sig

keyid class-attribute instance-attribute

keyid = None

cert class-attribute instance-attribute

cert = None

from_mapping classmethod

from_mapping(data)

Construct a signature record from a mapping.

Source code in swarmauri_signing_dsse/types.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
@classmethod
def from_mapping(cls, data: Mapping[str, object]) -> "DSSESignatureRecord":
    """Construct a signature record from a mapping."""

    if "sig" not in data:
        raise ValueError("DSSE signature mapping is missing the 'sig' field")
    sig_value = data["sig"]
    if not isinstance(sig_value, str):
        raise TypeError("DSSE signature field 'sig' must be a base64 string")

    keyid_value = data.get("keyid")
    if keyid_value is not None and not isinstance(keyid_value, str):
        raise TypeError(
            "DSSE signature field 'keyid' must be a string when provided"
        )

    cert_value = data.get("cert")
    if cert_value is not None and not isinstance(cert_value, str):
        raise TypeError(
            "DSSE signature field 'cert' must be a PEM string when provided"
        )

    return cls(sig=sig_value, keyid=keyid_value, cert=cert_value)

to_mapping

to_mapping()

Return the JSON-serializable mapping representation.

Source code in swarmauri_signing_dsse/types.py
41
42
43
44
45
46
47
48
49
def to_mapping(self) -> MutableMapping[str, str]:
    """Return the JSON-serializable mapping representation."""

    mapping: MutableMapping[str, str] = {"sig": self.sig}
    if self.keyid is not None:
        mapping["keyid"] = self.keyid
    if self.cert is not None:
        mapping["cert"] = self.cert
    return mapping