%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/jwt/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/jwt/__pycache__/api_jws.cpython-312.pyc

�

d��d[+��b�ddlmZddlZddlZddlZddlmZmZddlm	Z	m
Z
mZmZddl
mZmZmZmZddlmZmZddlmZerdd	lmZmZGd
�d�Ze�Zej4Zej6Zej8Zej:Zej<Zej>Zej@Z y)�)�annotationsN)�
TYPE_CHECKING�Any�)�	Algorithm�get_default_algorithms�
has_crypto�requires_cryptography)�DecodeError�InvalidAlgorithmError�InvalidSignatureError�InvalidTokenError)�base64url_decode�base64url_encode)�RemovedInPyjwt3Warning)�AllowedPrivateKeys�AllowedPublicKeysc� �eZdZdZ		d					dd�Zedd��Zdd�Zdd�Zdd�Z	dd�Z
					d															dd	�Z				d											dd
�Z				d											dd�Z
dd�Zdd
�Z		d											d d�Zd!d�Zd"d�Zy)#�PyJWS�JWTNc�2�t�|_|�t|�nt|j�|_t	|jj��D]}||jvs�|j|=� |�i}i|j
��|�|_y)N)r�_algorithms�set�_valid_algs�list�keys�_get_default_options�options)�self�
algorithmsr�keys    �-/usr/lib/python3/dist-packages/jwt/api_jws.py�__init__zPyJWS.__init__s���
2�3���)�5�C�
�O�3�t�?O�?O�;P�	
��
��(�(�-�-�/�0�	*�C��$�*�*�*��$�$�S�)�	*��?��G�A�$�3�3�5�A��A���c�
�ddiS)N�verify_signatureT�r'r$r"rzPyJWS._get_default_options1s
��"�D�)�)r$c��||jvrtd��t|t�st	d��||j|<|j
j
|�y)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_algorithm5sX���T�%�%�%��?�@�@��'�9�-��?�@�@�#*����� ������V�$r$c��||jvrtd��|j|=|jj|�y)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_algorithmBsH��
��)�)�)��1��
�

���V�$�������'r$c�,�t|j�S)zM
        Returns a list of supported values for the 'alg' parameter.
        )rr)rs r"�get_algorithmszPyJWS.get_algorithmsPs���D�$�$�%�%r$c��	|j|S#t$r/}ts|tvrt	d|�d��|�t	d�|�d}~wwxYw)z�
        For a given string name, return the matching Algorithm object.

        Example usage:

        >>> jws_obj.get_algorithm_by_name("RS256")
        zAlgorithm 'z9' could not be found. Do you have cryptography installed?�Algorithm not supportedN)rr1r	r
�NotImplementedError)r�alg_name�es   r"�get_algorithm_by_namezPyJWS.get_algorithm_by_nameVsc��	H��#�#�H�-�-���	H��(�.C�"C�)�!�(��+d�e����&�&?�@�a�G��	H�s��	A	�*A�A	c���g}|�|nd}	|r/|jd�}
|
r|d}	|jd�}|durd}|j|	d�}|r"|j|�|j|�|ds|d=|rd|d<nd|vr|d=t	j
|d||�	�j
�}
|jt|
��|r|}nt|�}|j|�d
j|�}|j|	�}|j|�}|j||�}|jt|��|rd|d<d
j|�}|jd
�S)N�none�alg�b64FT)�typr>r@)�,�:)�
separators�cls�	sort_keys�.r$r�utf-8)�get�
header_typ�_validate_headers�update�json�dumps�encode�appendr�joinr;�prepare_key�sign�decode)r�payloadr!�	algorithm�headers�json_encoder�is_payload_detached�sort_headers�segments�
algorithm_�headers_alg�headers_b64�header�json_header�msg_payload�
signing_inputr.�	signature�encoded_strings                   r"rNzPyJWS.encodegsy����(1�'<�)�&�
��!�+�+�e�,�K��$�U�^�
�!�+�+�e�,�K��e�#�&*�#�*.����!L����"�"�7�+��M�M�'�"��e�}��u�
��!�F�5�M�
�f�_��u�
��j�j��z�|�|�
�
�&�(�	�	���(��5�6��!�K�*�7�3�K�����$��	�	�(�+�
��,�,�Z�8���!�!�#�&���L�L���4�	����(��3�4���H�Q�K����8�,���$�$�W�-�-r$c��|r4tjdt|j����t�|�i}i|j
�|�}|d}|r
|st
d��|j|�\}	}
}}|jdd�dur5|�t
d��|}	dj|
jdd	�d
|	g�}
|r|j|
||||�|	||d�S)Nzypassing additional kwargs to decode_complete() is deprecated and will be removed in pyjwt version 3. Unsupported kwargs: r&z\It is required that you pass in a value for the "algorithms" argument when calling decode().r?TFz�It is required that you pass in a value for the "detached_payload" argument to decode a message having the b64 header set to false.rFrr)rTr^rb)�warnings�warn�tuplerrrr�_loadrHrP�rsplit�_verify_signature)
r�jwtr!r r�detached_payload�kwargs�merged_optionsr&rTrar^rbs
             r"�decode_completezPyJWS.decode_complete�s����M�M�'�',�V�[�[�]�';�&<�>�'�	
��?��G�4�D�L�L�4�G�4��)�*<�=���J��n��
�59�J�J�s�O�1����	��:�:�e�T�"�e�+��'�!�Z���'�G� �I�I�}�';�';�D�!�'D�Q�'G��&Q�R�M���"�"�=�&�)�S�*�U���"�
�	
r$c��|r4tjdt|j����t�|j|||||��}|dS)Nzppassing additional kwargs to decode() is deprecated and will be removed in pyjwt version 3. Unsupported kwargs: )rlrT)rerfrgrrro)rrkr!r rrlrm�decodeds        r"rSzPyJWS.decode�sc����M�M�'�',�V�[�[�]�';�&<�>�'�	
��&�&���j�'�<L�'�
���y�!�!r$c�P�|j|�d}|j|�|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
        �)rhrJ)rrkrVs   r"�get_unverified_headerzPyJWS.get_unverified_header�s)���*�*�S�/�!�$�����w�'��r$c��t|t�r|jd�}t|t�st	dt����	|jdd�\}}|j
dd�\}}	t|�}	tj|�}t|t�st	d��	t|�}
	t|�}|
|||fS#t$r}t	d�|�d}~wwxYw#ttjf$r}t	d�|�d}~wwxYw#t$r}	t	d|	���|	�d}	~	wwxYw#ttjf$r}t	d	�|�d}~wwxYw#ttjf$r}t	d
�|�d}~wwxYw)NrGz$Invalid token type. Token must be a rFrzNot enough segmentszInvalid header paddingzInvalid header string: z,Invalid header string: must be a json objectzInvalid payload paddingzInvalid crypto padding)r*�strrN�bytesrri�splitr)rr+�binascii�ErrorrL�loads�dict)rrkra�crypto_segment�header_segment�payload_segment�err�header_datar^r:rTrbs            r"rhzPyJWS._load�s����c�3���*�*�W�%�C��#�u�%�� D�U�G�L�M�M�	>�,/�J�J�t�Q�,?�)�M�>�.;�.A�.A�$��.J�+�N�O�	A�*�>�:�K�	D��Z�Z��,�F��&�$�'��L�M�M�	B�&��7�G�	A�(��8�I����	�:�:��5�	>��3�4�#�=��	>��
�8�>�>�*�	A��6�7�S�@��	A��
�	D�� 7��s�;�<�!�C��	D���8�>�>�*�	B��7�8�c�A��	B��
�8�>�>�*�	A��6�7�S�@��	A�sx�*C
�0C'�<D�-D4�9E!�
	C$�C�C$�'D�D�D�	D1�D,�,D1�4E�
E�E�!F�:F�Fc�"�	|d}|r|�||vrtd��	|j|�}|j	|�}	|j||	|�st
d��y#t$rtd��wxYw#t$r}td�|�d}~wwxYw)Nr>zAlgorithm not specifiedz&The specified alg value is not allowedr7zSignature verification failed)r1rr;r8rQ�verifyr
)
rrar^rbr!r r>r.r:�prepared_keys
          r"rjzPyJWS._verify_signatures���	C���-�C��z�-�#�Z�2G�'�(P�Q�Q�	J��0�0��5�G��*�*�3�/���~�~�m�\�9�E�'�(G�H�H�F���	C�'�(A�B�B�	C��#�	J�'�(A�B��I��	J�s"�A�A4�A1�4	B�=B	�	Bc�6�d|vr|j|d�yy)N�kid)�
_validate_kid)rrVs  r"rJzPyJWS._validate_headers8s!���G�����w�u�~�.�r$c�:�t|t�std��y)Nz(Key ID header parameter must be a string)r*rvr)rr�s  r"r�zPyJWS._validate_kid<s���#�s�#�#�$N�O�O�$r$)NN)r �list[str] | Noner�dict[str, Any] | None�return�None)r�zdict[str, bool])r-rvr.rr�r�)r-rvr�r�)r�z	list[str])r9rvr�r)�HS256NNFT)rTrwr!z AllowedPrivateKeys | str | bytesrUz
str | NonerVr�rWztype[json.JSONEncoder] | NonerX�boolrYr�r�rv)�NNN)rk�str | bytesr!�AllowedPublicKeys | str | bytesr r�rr�rl�bytes | Noner��dict[str, Any])rkr�r!r�r r�rr�rlr�r�r)rkr�r�r�)rkr�r�z*tuple[bytes, bytes, dict[str, Any], bytes])r�N)rarwr^r�rbrwr!r�r r�r�r�)rVr�r�r�)r�rr�r�)�__name__�
__module__�__qualname__rIr#�staticmethodrr/r3r5r;rNrorSrtrhrjrJr�r'r$r"rrs����J�(,�)-�B�$�B�'�B�
�	B�&�*��*�%�(�&�H�*!(�)-�6:�$)�!�C.��C.�.�C.��	C.�
'�C.�4�
C.�"�C.��C.�

�C.�P02�'+�)-�)-�
+
�
�+
�-�+
�%�	+
�
'�+
�'�
+
�
�+
�`02�'+�)-�)-�
"�
�"�-�"�%�	"�
'�"�'�
"�

�"�*	�$;�V02�'+�
I��I��I��	I�
-�I�%�
I�
�I�2/�Pr$r)!�
__future__rryrLre�typingrrr rrr	r
�
exceptionsrrr
r�utilsrrrrrr�_jws_global_objrNrorSr/r3r;rtr'r$r"�<module>r�s���"����%�����6�,��A�cP�cP�L	�'��	�	�	��!�1�1��	�	�	��$�7�7��&�;�;��'�=�=��'�=�=�r$

Zerion Mini Shell 1.0