spruceid / siwe-py

A Python implementation of Sign-In with Ethereum
https://login.xyz
Apache License 2.0
66 stars 28 forks source link

CustomDateTime Date Attribute Retention Issue with Multiple Values. #54

Closed lwcobo closed 3 months ago

lwcobo commented 9 months ago

When multiple CustomDateTime properties are present simultaneously (e.g., expiration_time and not_before), the date attribute of the CustomDateTime class retains only the last value.

        verification_time = datetime.now(UTC) if timestamp is None else timestamp
        if (
            self.expiration_time is not None
            and verification_time >= self.expiration_time.date
        ):
            raise ExpiredMessage
        if self.not_before is not None and verification_time <= self.not_before.date:
            raise NotYetValidMessage

The self.expiration_time.date will be identical to self.not_before.date, which is incorrect.

Here is the reason why this is happening:

    @classmethod
    def validate(cls, v: str):
        """Validate the format."""
        cls.date = isoparse(v)
        return cls(v)

date should be an attribute of the object rather than the class.