Skip to main content

TimestampSigner

This class extends the base Signer to include a timestamp in the signed output, allowing for time-limited signatures. It provides functionality to sign values with the current time and verify them against a maximum age during the unsigning process. If a signature has exceeded the specified duration, the class raises an exception to indicate expiration.

Constructor

Signature

def TimestampSigner() - > null

Methods


timestamp()

@classmethod
def timestamp() - > string

Generates a base62-encoded string representing the current Unix timestamp.

Returns

TypeDescription
stringA base62-encoded string of the current system time used for signing.

sign()

@classmethod
def sign(
value: string
) - > string

Appends a timestamp to the value before signing it to allow for expiration tracking.

Parameters

NameTypeDescription
valuestringThe raw string data that needs to be signed and timestamped.

Returns

TypeDescription
stringThe signed value containing the original data, the separator, the timestamp, and the signature.

unsign()

@classmethod
def unsign(
value: string,
max_age: integer|timedelta = null
) - > string

Retrieve original value and check it wasn't signed more than max_age seconds ago.

Parameters

NameTypeDescription
valuestringThe signed string containing the timestamp and signature to be verified.
max_age`integertimedelta` = null

Returns

TypeDescription
stringThe original unsigned value if the signature is valid and has not expired.