Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/itsdangerous/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/itsdangerous/__pycache__/timed.cpython-312.pyc

�

'ٜg����ddlmZddlmZddlZddlZddlmZddlm	Z	ddl
mZddl
mZddl
m
Z
dd	l
mZdd
l
mZddlmZddlmZdd
lmZddlmZddlmZddlmZGd�de�ZGd�dee�Zy)�)�annotationsN)�datetime)�timezone�)�
base64_decode)�
base64_encode)�bytes_to_int)�int_to_bytes)�
want_bytes)�BadSignature)�BadTimeSignature)�SignatureExpired)�_TSerialized)�
Serializer)�Signerc����eZdZdZd	d�Zd
d�Zdd�Zej		d							d
d��Z	ej		d							dd��Z			d							d�fd�
Z	ddd�Z
�xZS)�TimestampSignerz�Works like the regular :class:`.Signer` but also records the time
    of the signing and can be used to expire signatures. The
    :meth:`unsign` method can raise :exc:`.SignatureExpired` if the
    unsigning failed because the signature is expired.
    c�<�ttj��S)zTReturns the current timestamp. The function must return an
        integer.
        )�int�time)�selfs �=/usr/local/lib/python3.12/site-packages/itsdangerous/timed.py�
get_timestampzTimestampSigner.get_timestamps���4�9�9�;���c�L�tj|tj��S)a Convert the timestamp from :meth:`get_timestamp` into an
        aware :class`datetime.datetime` in UTC.

        .. versionchanged:: 2.0
            The timestamp is returned as a timezone-aware ``datetime``
            in UTC rather than a naive ``datetime`` assumed to be UTC.
        )�tz)r�
fromtimestampr�utc)r�tss  r�timestamp_to_datetimez%TimestampSigner.timestamp_to_datetime#s���%�%�b�X�\�\�:�:rc���t|�}tt|j���}t|j�}||z|z}||z|j|�zS)z:Signs the given string and also attaches time information.)rrr
r�sep�
get_signature)r�value�	timestampr"s    r�signzTimestampSigner.sign-sZ���5�!��!�,�t�/A�/A�/C�"D�E�	�����"�����i�'���s�{�T�/�/��6�6�6rc��y�N��r�signed_value�max_age�return_timestamps    r�unsignzTimestampSigner.unsign8s��rc��yr(r)r*s    rr.zTimestampSigner.unsign@s��"%rc�
��	t�|�|�}d}t	|j
�}||vr|r|�t
d|���|j|d�\}}	d}
d}	tt|	��}
|�+|
�	|j|
�}t
t|�||���|
�
t
d|���|�b|j!�|
z
}
|
|kDr$t#d|
�d	|�d
�||j|
����|
dkr!t#d|
�d�||j|
����|r||j|
�fS|S#t$r}|}|jxsd}Yd}~��0d}~wwxYw#t$rY��wxYw#tttf$r}t
d|��|�d}~wwxYw)
a�Works like the regular :meth:`.Signer.unsign` but can also
        validate the time. See the base docstring of the class for
        the general behavior. If ``return_timestamp`` is ``True`` the
        timestamp of the signature will be returned as an aware
        :class:`datetime.datetime` object in UTC.

        .. versionchanged:: 2.0
            The timestamp is returned as a timezone-aware ``datetime``
            in UTC rather than a naive ``datetime`` assumed to be UTC.
        Nrztimestamp missing)�payloadrzMalformed timestamp)r1�date_signedzSignature age z > z secondsrz < 0 seconds)�superr.rr1rr"r
�rsplitr	r�	Exceptionr �
ValueError�OSError�
OverflowError�strrr)rr+r,r-�result�	sig_error�er"r$�ts_bytes�ts_int�ts_dt�exc�age�	__class__s              �rr.zTimestampSigner.unsignHs���� 	&��W�^�L�1�F��I�
����"���f�����"�#6��G�G� �-�-��Q�/���x�!��!%��	�!�-��"9�:�F�� ��!�� �6�6�v�>�E�#�3�y�>�5�e�T�T��>�"�#8�%�H�H����$�$�&��/�C��W�}�&�$�S�E��W�I�X�>�!� $� :� :�6� B����Q�w�&�$�S�E��6�!� $� :� :�6� B�����$�4�4�V�<�<�<����G�	&��I��Y�Y�%�#�F��	&��.�	��	��#�G�]�;��+�-�u������sA�D#�E�1E�#	E	�,E�E	�	E�E�F�/E=�=Fc�J�	|j||��y#t$rYywxYw)zeOnly validates the given signed value. Returns ``True`` if
        the signature exists and is valid.)r,TF)r.r)rr+r,s   r�validatezTimestampSigner.validate�s,��	��K�K��g�K�6����	��	�s��	"�")�returnr)rrrEr)r$�str | bytesrE�bytes)NF)r+rFr,�
int | Noner-zt.Literal[False]rErG)NT)r+rFr,rHr-zt.Literal[True]rEztuple[bytes, datetime])r+rFr,rHr-�boolrEztuple[bytes, datetime] | bytesr()r+rFr,rHrErI)�__name__�
__module__�__qualname__�__doc__rr r&�t�overloadr.rD�
__classcell__�rBs@rrrs����� �;�7��Z�Z�#�-2�	�!����+�	�

�����Z�Z�#�,0�	%�!�%��%�*�	%�

 �%��%�#�!&�	V�!�V��V��	V�

(�V�p�rrc�|��eZdZUdZeZded<	d			d�fd�
Z			d										d
d�Z		d							dd�Z	�xZ
S)
�TimedSerializerzOUses :class:`TimestampSigner` instead of the default
    :class:`.Signer`.
    ztype[TimestampSigner]�default_signerc�J��tjdt�|�
|��S)N�cabc.Iterator[TimestampSigner])rN�castr3�iter_unsigners)r�saltrBs  �rrXzTimedSerializer.iter_unsigners�s!����v�v�6���8N�t�8T�U�Urc�&�t|�}d}|j|�D]6}	|j||d��\}}|j|�}	|r|	|fcS|	cSt
jt
|��#t$r�t
$r}
|
}Yd}
~
�ld}
~
wwxYw)a�Reverse of :meth:`dumps`, raises :exc:`.BadSignature` if the
        signature validation fails. If a ``max_age`` is provided it will
        ensure the signature is not older than that time in seconds. In
        case the signature is outdated, :exc:`.SignatureExpired` is
        raised. All arguments are forwarded to the signer's
        :meth:`~TimestampSigner.unsign` method.
        NT)r,r-)rrXr.�load_payloadrrrNrW)r�sr,r-rY�last_exception�signer�base64dr%r1�errs           r�loadszTimedSerializer.loads�s���
�q�M�����)�)�$�/�F�
%�%+�]�]��w��&3�&�"����+�+�G�4��#�"�I�-�-���0�$�f�f�\�>�2�2��$�
���
%�!$���
%�s�-A2�A2�2B�B�Bc�.�|j||d|i��S)Nr,)�load_kwargs)�_loads_unsafe_impl)rr\r,rYs    r�loads_unsafezTimedSerializer.loads_unsafe�s!���&�&�q�$�Y��<P�&�Q�Qrr()rY�str | bytes | NonerErV)NFN)
r\rFr,rHr-rIrYrfrEzt.Any)NN)r\rFr,rHrYrfrEztuple[bool, t.Any])rJrKrLrMrrT�__annotations__rXrarerPrQs@rrSrS�s�����-<�N�)�;�*.�V�&�V�	'�V�#�!&�#'�#3��#3��#3��	#3�
!�#3�
�
#3�P#�#'�	R��R��R�!�	R�

�RrrS)�
__future__r�collections.abc�abc�cabcr�typingrNrr�encodingrrr	r
rr@rr
r�
serializerrrr^rrrSr)rr�<module>rosZ��"������#�#�"�"� ��!�!�$�"��Q�f�Q�h:R�j��.�:Rr

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists