trailofbits / pypi-attestations

A library to convert between Sigstore Bundles and PEP 740 Attestation objects
https://trailofbits.github.io/pypi-attestations
Apache License 2.0
1 stars 1 forks source link

New APIs: `AttestationPayload` and helpers #5

Closed woodruffw closed 5 months ago

woodruffw commented 5 months ago

As part of making signing simple, I think we should expose these APIs as well. Per PEP 740, this would look roughly like:

class AttestationPayload:
    distribution: str
    """
    The file name of the Python package distribution.
    """

    digest: str
    """
    The SHA-256 digest of the distribution's contents, as a hexadecimal string.
    """

    @classmethod
    def from_dist(cls, dist: Path) -> Self:
        ...

    def __bytes__(self) -> bytes:
        return rfc8785.dumps(self.dict())

Thoughts @facutuesca?