� M�g����ddlmZddlmZddlZddlZddlmZddlm Z ddl m Z ddl m Z ddl m Z dd l mZdd l mZdd lmZdd lmZdd lmZddlmZddlmZddlmZGd�de��ZGd�dee��ZdS)�)� annotationsN)�datetime)�timezone�)� base64_decode)� base64_encode)� bytes_to_int)� int_to_bytes)� want_bytes)� BadSignature)�BadTimeSignature)�SignatureExpired)� _TSerialized)� Serializer)�Signerc���eZdZdZdd�Zdd�Zdd �Zej dd d���Z ej d!d"d���Z dd#�fd� Z d$d%d�Z �xZ S)&�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. �return�intc�B�ttj����S)zTReturns the current timestamp. The function must return an integer. )r�time)�selfs �b/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/itsdangerous/timed.py� get_timestampzTimestampSigner.get_timestamps���4�9�;�;�����tsrc�B�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)rrs r�timestamp_to_datetimez%TimestampSigner.timestamp_to_datetime#s���%�b�X�\�:�:�:�:r�value� str | bytes�bytesc���t|��}tt|�������}t|j��}||z|z}||z|�|��zS)z:Signs the given string and also attaches time information.)r rr r�sep� get_signature)rr"� timestampr&s r�signzTimestampSigner.sign-sj���5�!�!��!�,�t�/A�/A�/C�/C�"D�"D�E�E� ����"�"���� �i�'���s�{�T�/�/��6�6�6�6rNF� signed_value�max_age� int | None�return_timestamp�t.Literal[False]c��dS�N��rr*r+r-s r�unsignzTimestampSigner.unsign8s �� �rT�t.Literal[True]�tuple[bytes, datetime]c��dSr0r1r2s rr3zTimestampSigner.unsign@s �� "%�r�bool�tuple[bytes, datetime] | bytesc��� t���|��}d}n"#t$r}|}|jpd}Yd}~nd}~wwxYwt |j��}||vr|r|�t d|����|�|d��\}} d} d} tt| ����} n#t$rYnwxYw|�i| �H |� | ��} n1#tttf$r} t d|���| �d} ~ wwxYwt t|��|| ����| �t d|����|�x|���| z } | |kr,t#d| �d |�d �||� | ������| d kr)t#d| �d �||� | ������|r||� | ��fS|S) 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)r:� date_signedzSignature age z > z secondsrz < 0 seconds)�superr3r r:r r&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 �rr3zTimestampSigner.unsignHsu���  &��W�W�^�^�L�1�1�F��I�I��� &� &� &��I��Y�%�#�F�F�F�F�F�F����� &�������"�"�� �f� � �� ���"�#6��G�G�G� G� �-�-��Q�/�/���x�!��!%�� �!�-��"9�"9�:�:�F�F��� � � � �D� ���� � ��!�� �6�6�v�>�>�E�E��"�G�]�;����+�-�u��������������#�3�y�>�>�5�e�T�T�T� T� �>�"�#8�%�H�H�H� H� � ��$�$�&�&��/�C��W�}�}�&�>�S�>�>�W�>�>�>�!� $� :� :�6� B� B����� �Q�w�w�&�6�S�6�6�6�!� $� :� :�6� B� B����� � =��$�4�4�V�<�<�<� <�� s>�#'� A� A�A�B1�1 B>�=B>�C�D �3D�D c�X� |�||���dS#t$rYdSwxYw)zeOnly validates the given signed value. Returns ``True`` if the signature exists and is valid.)r+TF)r3r )rr*r+s r�validatezTimestampSigner.validate�sD�� � �K�K� �g�K� 6� 6� 6��4��� � � ��5�5� ���s �� )�))rr)rrrr)r"r#rr$)NF)r*r#r+r,r-r.rr$)NT)r*r#r+r,r-r4rr5)r*r#r+r,r-r7rr8r0)r*r#r+r,rr7) �__name__� __module__� __qualname__�__doc__rr!r)�t�overloadr3rM� __classcell__�rKs@rrrs���������  � � � � ;�;�;�;�7�7�7�7��Z�#�-2� �����Z���Z�#�,0� %�%�%�%��Z�%�#�!&� V�V�V�V�V�V�V�p��������rrc�V��eZdZUdZeZded< dd�fd � Z ddd�Z ddd�Z �xZ S)�TimedSerializerzOUses :class:`TimestampSigner` instead of the default :class:`.Signer`. ztype[TimestampSigner]�default_signerN�salt�str | bytes | Noner�cabc.Iterator[TimestampSigner]c�l��tjdt���|����S)Nr[)rR�castr<�iter_unsigners)rrYrKs �rr^zTimedSerializer.iter_unsigners�s*����v�6����8N�8N�t�8T�8T�U�U�UrF�sr#r+r,r-r7�t.Anyc�F�t|��}d}|�|��D]a} |�||d���\}}|�|��} |r| |fcS| cS#t$r�t $r } | }Yd} ~ �Zd} ~ wwxYwt jt |���)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-)r r^r3� load_payloadrr rRr]) rr_r+r-rY�last_exception�signer�base64dr(r:�errs r�loadszTimedSerializer.loads�s��� �q�M�M�����)�)�$�/�/� %� %�F� %�%+�]�]��w��&3�&�&�"����+�+�G�4�4��#�.�"�I�-�-�-�-������#� � � ��� %� %� %�!$����������� %�����f�\�>�2�2�2s�5A&�"A&�&B�:B�B�tuple[bool, t.Any]c�6�|�||d|i���S)Nr+)� load_kwargs)�_loads_unsafe_impl)rr_r+rYs r� loads_unsafezTimedSerializer.loads_unsafe�s$�� �&�&�q�$�Y��<P�&�Q�Q�Qrr0)rYrZrr[)NFN) r_r#r+r,r-r7rYrZrr`)NN)r_r#r+r,rYrZrrh) rNrOrPrQrrX�__annotations__r^rgrlrTrUs@rrWrW�s�����������-<�N�;�;�;�;�*.�V�V�V�V�V�V�V�#�!&�#'� #3�#3�#3�#3�#3�P#�#'� R�R�R�R�R�R�R�R�RrrW)� __future__r�collections.abc�abc�cabcr�typingrRrr�encodingrrr r r rIr r r� serializerrrrdrrrWr1rr�<module>rus���"�"�"�"�"�"������� � � � �����������������#�#�#�#�#�#�#�#�#�#�#�#�"�"�"�"�"�"�"�"�"�"�"�"� � � � � � �������!�!�!�!�!�!�!�!�!�!�!�!�$�$�$�$�$�$�"�"�"�"�"�"�������Q�Q�Q�Q�Q�f�Q�Q�Q�h:R�:R�:R�:R�:R�j��.�:R�:R�:R�:R�:Rr
Memory