Revocable, expiring consent for proactive delivery to one destination.
Summary
Functions
Returns true when the consent is neither revoked nor expired at now
(milliseconds); false otherwise, including for a non-integer now.
Builds a validated consent from a struct, map or keyword list.
Revokes the consent at at (milliseconds), returning the updated consent.
Validates the consent's identity, timestamps, channels and portability.
Types
Functions
@spec active?(t(), non_neg_integer()) :: boolean()
Returns true when the consent is neither revoked nor expired at now
(milliseconds); false otherwise, including for a non-integer now.
Builds a validated consent from a struct, map or keyword list.
Missing id and granted_at default to a fresh UUIDv7 and the current time.
Raises ArgumentError when the resulting consent is invalid.
@spec revoke(t(), non_neg_integer()) :: t()
Revokes the consent at at (milliseconds), returning the updated consent.
Idempotent: an already revoked consent is returned unchanged. Raises
ArgumentError when the revocation time precedes the grant time.
Validates the consent's identity, timestamps, channels and portability.
Returns :ok, or {:error, reason} naming the first invalid field.