HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberPanel/lib64/python3.10/site-packages/jose/__pycache__/jws.cpython-310.pyc
o

��h��@s�ddlZddlZz
ddlmZmZWney#ddlmZmZYnwddlmZddl	m
Z
ddlmZddl
mZmZddlmZmZdejfd	d
�Zd#dd
�Zdd�Zdd�Zdd�Zd$dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd%d!d"�ZdS)&�N)�Iterable�Mapping)rr)�jwk)�Key)�
ALGORITHMS)�JWSError�JWSSignatureError)�base64url_decode�base64url_encodecCs<|tjvrtd|��t||d�}t|�}t||||�}|S)awSigns a claims set and returns a JWS string.

    Args:
        payload (str or dict): A string to sign
        key (str or dict): The key to use for signing the claim set. Can be
            individual JWK or JWK set.
        headers (dict, optional): A set of headers that will be added to
            the default headers.  Any headers that are added as additional
            headers will override the default headers.
        algorithm (str, optional): The algorithm to use for signing the
            the claims.  Defaults to HS256.

    Returns:
        str: The string representation of the header, claims, and signature.

    Raises:
        JWSError: If there is an error signing the token.

    Examples:

        >>> jws.sign({'a': 'b'}, 'secret', algorithm='HS256')
        'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhIjoiYiJ9.jiMyrsmD8AoHWeQgmxZ5yq8z0lXS67_QGs52AzC8Ru8'

    zAlgorithm %s not supported.)�additional_headers)r�	SUPPORTEDr�_encode_header�_encode_payload�_sign_header_and_claims)�payload�key�headers�	algorithm�encoded_header�encoded_payload�
signed_output�r�>/usr/local/CyberPanel/lib/python3.10/site-packages/jose/jws.py�signs
rTcCs(t|�\}}}}|rt|||||�|S)a�Verifies a JWS string's signature.

    Args:
        token (str): A signed JWS to be verified.
        key (str or dict): A key to attempt to verify the payload with. Can be
            individual JWK or JWK set.
        algorithms (str or list): Valid algorithms that should be used to verify the JWS.

    Returns:
        str: The str representation of the payload, assuming the signature is valid.

    Raises:
        JWSError: If there is an exception verifying a token.

    Examples:

        >>> token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhIjoiYiJ9.jiMyrsmD8AoHWeQgmxZ5yq8z0lXS67_QGs52AzC8Ru8'
        >>> jws.verify(token, 'secret', algorithms='HS256')

    )�_load�_verify_signature)�tokenr�
algorithms�verify�headerr�
signing_input�	signaturerrrr4srcCst|�\}}}}|S)a!Returns the decoded headers without verification of any kind.

    Args:
        token (str): A signed JWS to decode the headers from.

    Returns:
        dict: The dict representation of the token headers.

    Raises:
        JWSError: If there is an exception decoding the token.
    �r�rr�claimsr r!rrr�get_unverified_headerR�r%cCst|�S)a{Returns the decoded headers without verification of any kind.

    This is simply a wrapper of get_unverified_header() for backwards
    compatibility.

    Args:
        token (str): A signed JWS to decode the headers from.

    Returns:
        dict: The dict representation of the token headers.

    Raises:
        JWSError: If there is an exception decoding the token.
    )r%)rrrr�get_unverified_headersbsr'cCst|�\}}}}|S)aReturns the decoded claims without verification of any kind.

    Args:
        token (str): A signed JWS to decode the headers from.

    Returns:
        str: The str representation of the token claims.

    Raises:
        JWSError: If there is an exception decoding the token.
    r"r#rrr�get_unverified_claimstr&r(cCs6d|d�}|r|�|�tj|ddd��d�}t|�S)N�JWT)�typ�alg��,�:T)�
separators�	sort_keys�utf-8)�update�json�dumps�encoder
)rrr�json_headerrrrr
�s

��r
cCsJt|t�r!ztj|dd��d�}Wt|�Sty Yt|�Swt|�S)Nr,)r/r1)�
isinstancerr3r4r5�
ValueErrorr
)rrrrr�s
����rc	
Csvd�||g�}zt|t�st�||�}|�|�}Wnty)}zt|��d}~wwt|�}d�|||g�}|�	d�S)N�.r1)
�joinr7rr�	constructr�	Exceptionrr
�decode)	r�encoded_claimsrrr r!�e�encoded_signature�encoded_stringrrrr�s
��
rc

Cst|t�r
|�d�}z|�dd�\}}|�dd�\}}t|�}Wnty+td��tt	j
fy8td��wz
t�|�
d��}WntyU}ztd|��d}~wwt|t�s_td��zt|�}Wntt	j
fystd��wzt|�}	Wntt	j
fy�td	��w||||	fS)
Nr1r9�zNot enough segmentszInvalid header paddingzInvalid header string: %sz,Invalid header string: must be a json objectzInvalid payload paddingzInvalid crypto padding)r7�strr5�rsplit�splitr	r8r�	TypeError�binascii�Errorr3�loadsr=r)
�jwtr �crypto_segment�header_segment�claims_segment�header_datarr?rr!rrrr�s<

���
��rc	CsN|D]"}t|t�st�||�}z|�||�rWdSWqty$YqwdS)NTF)r7rrr;rr<)�keysr r!r+rrrr�_sig_matches_keys�s
��rPcCs�t|t�r|fSz
tj|ttd�}Wn	tyYnwt|t�r;d|vr)|dSd|vr0|fS|��}|r8|S|fSt|t�rLt|t�sLt|t	�sL|S|fS)N)�	parse_int�parse_floatrO�kty)
r7rr3rIrCr<r�valuesr�bytes)rrTrrr�	_get_keys�s&
�
rV�cCs�|�d�}|std��|dur||vrtd��t|�}z
t||||�s&t��WdSty3td��ty?td|��w)Nr+z-No algorithm was specified in the JWS header.z&The specified alg value is not allowedzSignature verification failed.z$Invalid or unsupported algorithm: %s)�getrrVrPr)r rr!rrr+rOrrrr�s
��r)T)N)rWN) rGr3�collections.abcrr�ImportError�collections�joser�jose.backends.baser�jose.constantsr�jose.exceptionsrr�
jose.utilsr	r
�HS256rrr%r'r(r
rrrrPrVrrrrr�<module>s0�
$

!