Your IP : 18.119.124.24


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

�

O�Dg����ddlZddlZddlmZddlmZmZmZmZm	Z	ddl
mZmZm
Z
mZddlmZmZmZmZddlmZmZGd�d	��Ze��ZejZejZejZejZejZejZdS)
�N)�Mapping)�Any�Dict�List�Optional�Type�)�	Algorithm�get_default_algorithms�
has_crypto�requires_cryptography)�DecodeError�InvalidAlgorithmError�InvalidSignatureError�InvalidTokenError)�base64url_decode�base64url_encodec
�,�eZdZdZdd�Zed���Zd�Zd�Zd�Z				dd	e
d
ededee
d
eeejdefd�Z			dded
edeede
de
eeff
d�Z			dded
edeede
def
d�Zd�Zd�Z		dd�Zd�Zd�ZdS)�PyJWS�JWTNc�6�t��|_|�t|��nt|j��|_t	|j�����D]}||jvr|j|=�|�i}i|����|�|_dS)N)r�_algorithms�set�_valid_algs�list�keys�_get_default_options�options)�self�
algorithmsr�keys    �k/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib/python3.11/site-packages/jwt/api_jws.py�__init__zPyJWS.__init__s���1�3�3���)�5�C�
�O�O�O�3�t�?O�;P�;P�	
��
��(�-�-�/�/�0�0�	*�	*�C��$�*�*�*��$�S�)���?��G�A�$�3�3�5�5�A��A�����c�
�ddiS)N�verify_signatureT�r'r$r"rzPyJWS._get_default_options's
��"�D�)�)r$c���||jvrtd���t|t��st	d���||j|<|j�|��dS)zW
        Registers a new Algorithm for use when creating and verifying tokens.
        z Algorithm already has a handler.z!Object is not of type `Algorithm`N)r�
ValueError�
isinstancer
�	TypeErrorr�add)r�alg_id�alg_objs   r"�register_algorithmzPyJWS.register_algorithm+sm���T�%�%�%��?�@�@�@��'�9�-�-�	A��?�@�@�@�#*���� �����V�$�$�$�$�$r$c�z�||jvrtd���|j|=|j�|��dS)z�
        Unregisters an Algorithm for use when creating and verifying tokens
        Throws KeyError if algorithm is not registered.
        zJThe specified algorithm could not be removed because it is not registered.N)r�KeyErrorr�remove)rr-s  r"�unregister_algorithmzPyJWS.unregister_algorithm8sS��
��)�)�)��1���
�

��V�$������'�'�'�'�'r$c�*�t|j��S)zM
        Returns a list of supported values for the 'alg' parameter.
        )rr)rs r"�get_algorithmszPyJWS.get_algorithmsFs���D�$�%�%�%r$�HS256�payloadr!�	algorithm�headers�json_encoder�returnc��g}|�d}||jvr	|j|d�}|r*|�|��|�|��t	j|d|������}|�t|����|�t|����d�	|��}		|j
|}
|
�|��}|
�|	|��}n?#t$r2ts|tvrt!d|z���t!d���wxYw|�t|����d�	|��}|�d��S)	N�none)�typ�alg)�,�:)�
separators�cls�.zFAlgorithm '%s' could not be found. Do you have cryptography installed?�Algorithm not supported�utf-8)r�
header_typ�_validate_headers�update�json�dumps�encode�appendr�joinr�prepare_key�signr1rr
�NotImplementedError�decode)
rr7r!r8r9r:�segments�header�json_header�
signing_inputr.�	signature�encoded_strings
             r"rLzPyJWS.encodeLs��������I��D�,�,�,�����;�;���	#��"�"�7�+�+�+��M�M�'�"�"�"��j��z�|�
�
�
�
�&�(�(�	�	���(��5�5�6�6�6����(��1�1�2�2�2��	�	�(�+�+�
�	E��&�y�1�G��%�%�c�*�*�C����]�C�8�8�I�I���	E�	E�	E��
E�)�/D�"D�"D�)�!�#,�-����
*�*C�D�D�D�	E����	���(��3�3�4�4�4����8�,�,���$�$�W�-�-�-s�
8D�<D?��jwtr rc���|�i}i|j�|�}|d}|r|std���|�|��\}}	}
}|r|�|	|
|||��||
|d�S)Nr&z\It is required that you pass in a value for the "algorithms" argument when calling decode().)r7rTrW)rr�_load�_verify_signature)rrZr!r r�kwargs�merged_optionsr&r7rVrTrWs            r"�decode_completezPyJWS.decode_complete�s����?��G�4�D�L�4�G�4��)�*<�=���	�J�	��n���
�59�J�J�s�O�O�1����	��	V��"�"�=�&�)�S�*�U�U�U���"�
�
�	
r$c�4�|j||||fi|��}|dS)Nr7)r`)rrZr!r rr^�decodeds       r"rRzPyJWS.decode�s/��'�$�&�s�C��W�O�O��O�O���y�!�!r$c�f�|�|��d}|�|��|S)z�Returns back the JWT header parameters as a dict()

        Note: The signature is not verified so the header parameters
        should not be fully trusted until signature verification is complete
        �)r\rH)rrZr9s   r"�get_unverified_headerzPyJWS.get_unverified_header�s1���*�*�S�/�/�!�$�����w�'�'�'��r$c��t|t��r|�d��}t|t��st	dt�����	|�dd��\}}|�dd��\}}n"#t$r}t	d��|�d}~wwxYw	t|��}n.#ttjf$r}t	d��|�d}~wwxYw	tj
|��}n%#t$r}	t	d|	z��|	�d}	~	wwxYwt|t��st	d���	t|��}
n.#ttjf$r}t	d	��|�d}~wwxYw	t|��}n.#ttjf$r}t	d
��|�d}~wwxYw|
|||fS)NrFz$Invalid token type. Token must be a rDr	zNot enough segmentszInvalid header paddingzInvalid header string: %sz,Invalid header string: must be a json objectzInvalid payload paddingzInvalid crypto padding)r*�strrL�bytesr�rsplit�splitr)rr+�binascii�ErrorrJ�loadsr)rrZrV�crypto_segment�header_segment�payload_segment�err�header_datarT�er7rWs            r"r\zPyJWS._load�s-���c�3���	&��*�*�W�%�%�C��#�u�%�%�	N��L�U�L�L�M�M�M�	>�,/�J�J�t�Q�,?�,?�)�M�>�.;�.A�.A�$��.J�.J�+�N�O�O���	>�	>�	>��3�4�4�#�=�����	>����	A�*�>�:�:�K�K���8�>�*�	A�	A�	A��6�7�7�S�@�����	A����	F��Z��,�,�F�F���	F�	F�	F��9�A�=�>�>�A�E�����	F�����&�'�*�*�	N��L�M�M�M�	B�&��7�7�G�G���8�>�*�	B�	B�	B��7�8�8�c�A�����	B����	A�(��8�8�I�I���8�>�*�	A�	A�	A��6�7�7�S�@�����	A�������	�:�:sx�2B�
B*�B%�%B*�.B>�>C)�C$�$C)�-D�
D$�D�D$�E�F�2F�F�F�G�1G�Gc�&�|�d��}|�||vrtd���	|j|}|�|��}|�|||��std���dS#t$rtd���wxYw)Nr?z&The specified alg value is not allowedzSignature verification failedrE)�getrrrO�verifyrr1)rrVrTrWr!r r?r.s        r"r]zPyJWS._verify_signature�s����j�j������!�c��&;�&;�'�(P�Q�Q�Q�	C��&�s�+�G��%�%�c�*�*�C��>�>�-��i�@�@�
M�+�,K�L�L�L�
M�
M���	C�	C�	C�'�(A�B�B�B�	C���s�AA6�6Bc�H�d|vr|�|d��dSdS)N�kid)�
_validate_kid)rr9s  r"rHzPyJWS._validate_headers�s3���G������w�u�~�.�.�.�.�.��r$c�N�t|t��std���dS)Nz(Key ID header parameter must be a string)r*rgr)rrxs  r"ryzPyJWS._validate_kid�s0���#�s�#�#�	P�#�$N�O�O�O�	P�	Pr$)NN)r6NN)rYNN)rYN)�__name__�
__module__�__qualname__rGr#�staticmethodrr/r3r5rhrgrrrrJ�JSONEncoderrLrrr`rRrer\r]rHryr'r$r"rrs�������J�
B�
B�
B�
B��*�*��\�*�%�%�%�(�(�(�&�&�&�!�"&�9=�
2.�2.��2.��2.��	2.�
�$��2.��t�D�$4�5�6�
2.�

�2.�2.�2.�2.�n� $��
�
�
�
��
���I�	
�
�
�
�c�3�h��
�
�
�
�@� $��	"�	"�
�	"��	"���I�		"�
�	"�

�	"�	"�	"�	"�	�	�	�$;�$;�$;�V
��
C�C�C�C�0/�/�/�P�P�P�P�Pr$r)rkrJ�collections.abcr�typingrrrrrr r
rrr
�
exceptionsrrrr�utilsrrr�_jws_global_objrLr`rRr/r3rer'r$r"�<module>r�sd����������#�#�#�#�#�#�2�2�2�2�2�2�2�2�2�2�2�2�2�2�������������������������6�5�5�5�5�5�5�5�bP�bP�bP�bP�bP�bP�bP�bP�J�%�'�'��	�	��!�1��	�	��$�7��&�;��'�=���r$

?>