Your IP : 3.137.200.139


Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/jwt/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/jwt/__pycache__/api_jwt.cpython-311.pyc

�

��bg^1���ddlmZddlZddlZddlmZddlmZddlmZm	Z	m
Z
ddlmZm
Z
ddlmZdd	lmZmZmZmZmZmZmZdd
lmZerddlmZmZGd�d
��Ze��ZejZejZej Z dS)�)�annotationsN)�timegm)�Iterable)�datetime�	timedelta�timezone)�
TYPE_CHECKING�Any�)�api_jws)�DecodeError�ExpiredSignatureError�ImmatureSignatureError�InvalidAudienceError�InvalidIssuedAtError�InvalidIssuerError�MissingRequiredClaimError)�RemovedInPyjwt3Warning)�AllowedPrivateKeys�AllowedPublicKeysc���eZdZd<d=d�Zed>d���Z				d?d@d�Z		dAdBd�Z								dCdDd,�ZdEd.�Z									dCdFd/�Z
			dGdHd0�ZdId1�ZdJd4�Z
dJd5�ZdJd6�Zd7d8�dKd:�ZdLd;�ZdS)M�PyJWTN�options�dict[str, Any] | None�return�Nonec�H�|�i}i|����|�|_dS�N)�_get_default_optionsr)�selfrs  �B/opt/cloudlinux/venv/lib64/python3.11/site-packages/jwt/api_jwt.py�__init__zPyJWT.__init__s-���?��G�'Q�$�*C�*C�*E�*E�'Q��'Q������dict[str, bool | list[str]]c��ddddddgd�S)NT)�verify_signature�
verify_exp�
verify_nbf�
verify_iat�
verify_aud�
verify_iss�require�r-r#r!rzPyJWT._get_default_options s(��!%�������
�
�	
r#�HS256T�payload�dict[str, Any]�key� AllowedPrivateKeys | str | bytes�	algorithm�
str | None�headers�json_encoder�type[json.JSONEncoder] | None�sort_headers�bool�strc��t|t��std���|���}dD]T}t|�|��t
��r*t
||�����||<�U|�|||���}tj
||||||���S)NzGExpecting a dict object, as JWT only supports JSON objects as payloads.)�exp�iat�nbf)r5r6)r8)�
isinstance�dict�	TypeError�copy�getrr�utctimetuple�_encode_payloadr�encode)	r r/r1r3r5r6r8�
time_claim�json_payloads	         r!rFzPyJWT.encode,s����'�4�(�(�	��,���
��,�,�.�.��/�	Q�	Q�J��'�+�+�j�1�1�8�<�<�
Q�&,�W�Z�-@�-M�-M�-O�-O�&P�&P��
�#���+�+���%�,�
�
���~������%�

�
�
�	
r#�bytesc�V�tj|d|����d��S)z�
        Encode a given payload to the bytes to be signed.

        This method is intended to be overridden by subclasses that need to
        encode the payload in a different way, e.g. compress the payload.
        )�,�:)�
separators�clszutf-8)�json�dumpsrF)r r/r5r6s    r!rEzPyJWT._encode_payloadRs3���z��!��
�
�
��&��/�/�		r#�r�jwt�str | bytes�AllowedPublicKeys | str | bytes�
algorithms�list[str] | None�verify�bool | None�detached_payload�bytes | None�audience�str | Iterable[str] | None�issuer�leeway�float | timedelta�kwargsr
c
���|
r<tjdt|
�������t��t|pi��}|�dd��|�'||dkrtjdt���|dsn|�dd��|�dd��|�d	d��|�d
d��|�dd��|dr|std���tj
|||||�
��}|�|��}i|j�|�}
|�
||
|||	���||d<|S)Nzypassing additional kwargs to decode_complete() is deprecated and will be removed in pyjwt version 3. Unsupported kwargs: r&Tz�The `verify` argument to `decode` does nothing in PyJWT 2.0 and newer. The equivalent is setting `verify_signature` to False in the `options` dictionary. This invocation has a mismatch between the kwarg and the option entry.)�categoryr'Fr(r)r*r+z\It is required that you pass in a value for the "algorithms" argument when calling decode().)r1rUrrY)r[r]r^r/)�warnings�warn�tuple�keysrr@�
setdefault�DeprecationWarningr
r�decode_complete�_decode_payloadr�_validate_claims)r rRr1rUrrWrYr[r]r^r`�decodedr/�merged_optionss              r!rizPyJWT.decode_completeds���$�	��M�>�',�V�[�[�]�]�';�';�>�>�'�	
�
�
��w�}�"�%�%�����-�t�4�4�4�
��&�G�4F�,G�"G�"G��M�Y�,�	
�
�
�
��)�*�	4����|�U�3�3�3����|�U�3�3�3����|�U�3�3�3����|�U�3�3�3����|�U�3�3�3��%�&�	�z�	��n���
��)���!��-�
�
�
���&�&�w�/�/��4�D�L�4�G�4������^�h�v�f�	�	
�	
�	
�%��	���r#rlc���	tj|d��}n$#t$r}td|�����d}~wwxYwt	|t
��std���|S)a
        Decode the payload from a JWS dictionary (payload, signature, header).

        This method is intended to be overridden by subclasses that need to
        decode the payload in a different way, e.g. decompress compressed
        payloads.
        r/zInvalid payload string: Nz-Invalid payload string: must be a json object)rO�loads�
ValueErrorr
r?r@)r rlr/�es    r!rjzPyJWT._decode_payload�sz��	>��j���!3�4�4�G�G���	>�	>�	>��<��<�<�=�=�=�����	>�����'�4�(�(�	O��M�N�N�N��s��
>�9�>c
���|
r<tjdt|
�������t��|�|||||||||	��	�	}|dS)Nzppassing additional kwargs to decode() is deprecated and will be removed in pyjwt version 3. Unsupported kwargs: )rWrYr[r]r^r/)rcrdrerfrri)r rRr1rUrrWrYr[r]r^r`rls            r!�decodezPyJWT.decode�s���$�	��M�>�',�V�[�[�]�]�';�';�>�>�'�	
�
�
��&�&������-����'�

�

���y�!�!r#c��t|t��r|���}|�+t|ttf��std���|�||��tjtj
������}d|vr|dr|�|||��d|vr|dr|�
|||��d|vr|dr|�|||��|d	r|�||��|d
r.|�|||�dd���
��dSdS)Nz+audience must be a string, iterable or None)�tzr=r)r>r(r<r'r+r*�
strict_audF��strict)r?r�
total_secondsr:rrA�_validate_required_claimsr�nowr�utc�	timestamp�
_validate_iat�
_validate_nbf�
_validate_exp�
_validate_iss�
_validate_audrC)r r/rr[r]r^r{s       r!rkzPyJWT._validate_claims�s����f�i�(�(�	,��)�)�+�+�F���
�8�c�8�_�(M�(M���I�J�J�J��&�&�w��8�8�8��l�h�l�+�+�+�5�5�7�7���G����� 5�����w��V�4�4�4��G����� 5�����w��V�4�4�4��G����� 5�����w��V�4�4�4��<� �	0����w��/�/�/��<� �	������'�+�+�l�E�*J�*J�
�
�
�
�
�
�	�	r#c�d�|dD]&}|�|���t|����'dS)Nr,)rCr)r r/r�claims    r!rzzPyJWT._validate_required_claimssG��
�Y�'�	7�	7�E��{�{�5�!�!�)�/��6�6�6�*�	7�	7r#r{�floatc��	t|d��}n#t$rtd���wxYw|||zkrtd���dS)Nr=z)Issued At claim (iat) must be an integer.z The token is not yet valid (iat))�intrprr)r r/r{r^r=s     r!r~zPyJWT._validate_iatso��	T��g�e�n�%�%�C�C���	T�	T�	T�&�'R�S�S�S�	T�����#��,���(�)K�L�L�L� ����2c��	t|d��}n#t$rtd���wxYw|||zkrtd���dS)Nr>z*Not Before claim (nbf) must be an integer.z The token is not yet valid (nbf))r�rpr
r)r r/r{r^r>s     r!rzPyJWT._validate_nbfsq��	L��g�e�n�%�%�C�C���	L�	L�	L��J�K�K�K�	L�����#��,���(�)K�L�L�L� �r�c��	t|d��}n#t$rtd���wxYw|||z
krtd���dS)Nr<z/Expiration Time claim (exp) must be an integer.zSignature has expired)r�rpr
r)r r/r{r^r<s     r!r�zPyJWT._validate_exp&sq��	T��g�e�n�%�%�C�C���	T�	T�	T��R�S�S�S�	T�����3��<� � �'�(?�@�@�@�!� r�Frwrxc���|�d|vs|dsdStd���d|vs|dstd���|d�|r_t|t��std���t�t��std���|�krtd���dSt�t��r�g�t�t��std���td��D����rtd���t|t��r|g}t
�fd�|D����rtd	���dS)
N�audzInvalid audiencezInvalid audience (strict)z&Invalid claim format in token (strict)zAudience doesn't match (strict)zInvalid claim format in tokenc3�BK�|]}t|t��V��dSr)r?r:)�.0�cs  r!�	<genexpr>z&PyJWT._validate_aud.<locals>.<genexpr>]s/����?�?�!�:�a��%�%�%�?�?�?�?�?�?r#c3� �K�|]}|�vV��	dSrr-)r�r��audience_claimss  �r!r�z&PyJWT._validate_aud.<locals>.<genexpr>cs(�����>�>�c�s�/�)�>�>�>�>�>�>r#zAudience doesn't match)rrr?r:�list�any�all)r r/r[rxr�s    @r!r�zPyJWT._validate_aud4s�������G�#�#�7�5�>�#���'�'9�:�:�:�����w�u�~��,�E�2�2�2�!�%�.���	��h��,�,�
H�*�+F�G�G�G��o�s�3�3�
U�*�+S�T�T�T��?�*�*�*�+L�M�M�M��F��o�s�+�+�	0�.�/�O��/�4�0�0�	H�&�'F�G�G�G��?�?��?�?�?�?�?�	H�&�'F�G�G�G��h��$�$�	"� �z�H��>�>�>�>�X�>�>�>�>�>�	A�&�'?�@�@�@�	A�	Ar#c�j�|�dSd|vrtd���|d|krtd���dS)N�isszInvalid issuer)rr)r r/r]s   r!r�zPyJWT._validate_issfsK���>��F�����+�E�2�2�2��5�>�V�#�#�$�%5�6�6�6�$�#r#r)rrrr)rr$)r.NNT)r/r0r1r2r3r4r5rr6r7r8r9rr:)NN)r/r0r5rr6r7rrI)rQNNNNNNr)rRrSr1rTrUrVrrrWrXrYrZr[r\r]r4r^r_r`r
rr0)rlr0rr
)rRrSr1rTrUrVrrrWrXrYrZr[r\r]r4r^r_r`r
rr
)NNr)r/r0rr0r^r_rr)r/r0rr0rr)r/r0r{r�r^r�rr)r/r0r[r\rxr9rr)r/r0r]r
rr)�__name__�
__module__�__qualname__r"�staticmethodrrFrErirjrsrkrzr~rr�r�r�r-r#r!rrs�������R�R�R�R�R�
�	
�	
�	
��\�	
�!(�)-�6:�!�$
�$
�$
�$
�$
�R*.�6:�	�����*02�'+�)-�"�)-�04�!�$%�C�C�C�C�C�J����&02�'+�)-�"�)-�04�!�$%�$"�$"�$"�$"�$"�T��$%�
!�!�!�!�!�F7�7�7�7�M�M�M�M�M�M�M�M�A�A�A�A�&�0A�0A�0A�0A�0A�0A�d7�7�7�7�7�7r#r)!�
__future__rrOrc�calendarr�collections.abcrrrr�typingr	r
rQr�
exceptionsr
rrrrrrrrUrrr�_jwt_global_objrFrirsr-r#r!�<module>r�s~��"�"�"�"�"�"���������������$�$�$�$�$�$�2�2�2�2�2�2�2�2�2�2�%�%�%�%�%�%�%�%�������������������������-�,�,�,�,�,��B�A�A�A�A�A�A�A�A�T7�T7�T7�T7�T7�T7�T7�T7�n
�%�'�'��	�	��!�1��	�	���r#

?>