Format: application/x-python-code
1 o
2
3 .'h� � @ s� d dl mZ d dlmZ d dlZd dlZd dlmZ d dlm Z ddl
4 mZ ddl
5 mZ ddl
6 m
7 Z
8 dd l
9 mZ dd
10 l
11 mZ ddlmZ ddlmZ dd
12 lmZ ddlmZ ddlmZ ddlmZ G dd� de�ZG dd� dee �ZdS )� )�annotationsN)�datetime)�timezone� )�
13 base64_decode)�
14 base64_encode)�bytes_to_int)�int_to_bytes)�
15 want_bytes)�BadSignature)�BadTimeSignature)�SignatureExpired)�_TSerialized)�
16 Serializer)�Signerc s~ e Zd ZdZd!dd�Zd"dd �Zd#d
17 d�Zej d$d%dd��Z ej d&d'dd��Z d$d(� fdd�
18 Z d)d*dd �Z
19 � ZS )+�TimestampSignerz�Works like the regular :class:`.Signer` but also records the time
20 of the signing and can be used to expire signatures. The
21 :meth:`unsign` method can raise :exc:`.SignatureExpired` if the
22 unsigning failed because the signature is expired.
23 �return�intc C s t t�� �S )zTReturns the current timestamp. The function must return an
24 integer.
25 )r �time)�self� r �HC:\Users\shubh\Videos\agent\nova\Lib\site-packages\itsdangerous/timed.py�
26 get_timestamp s zTimestampSigner.get_timestamp�tsr c C s t j|tjd�S )a Convert the timestamp from :meth:`get_timestamp` into an
27 aware :class`datetime.datetime` in UTC.
28
29 .. versionchanged:: 2.0
30 The timestamp is returned as a timezone-aware ``datetime``
31 in UTC rather than a naive ``datetime`` assumed to be UTC.
32 )�tz)r �
33 fromtimestampr �utc)r r r r r �timestamp_to_datetime# s z%TimestampSigner.timestamp_to_datetime�value�str | bytes�bytesc C s@ t |�}tt| �� ��}t | j�}|| | }|| | �|� S )z:Signs the given string and also attaches time information.)r
34 r r r �sepZ
35 get_signature)r r � timestampr! r r r �sign- s
36
37 zTimestampSigner.signNF�signed_value�max_age�
38 int | None�return_timestamp�t.Literal[False]c C � d S �Nr �r r$ r% r'