HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //usr/lib/python3.9/site-packages/jwcrypto/__pycache__/common.cpython-39.opt-1.pyc
a

G�b�@s�ddlZddlZddlmZmZddlmZddlmZdd�Z	dd�Z
d	d
�Zdd�ZGd
d�de
�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Zedd�ZGdd �d e�ZdS)!�N)�urlsafe_b64decode�urlsafe_b64encode)�
namedtuple)�MutableMappingcCs,t|t�s|�d�}t|�}|�d��d�S)N�utf-8�=)�
isinstance�bytes�encoder�decode�rstrip)�payloadr
�r�3/usr/lib/python3.9/site-packages/jwcrypto/common.py�base64url_encode
s

rcCsNt|�d}|dkr|d7}n"|dkr0|d7}n|dkr@td��t|�d��S)	N��z==�rrzInvalid base64 stringr)�len�
ValueErrorrr
)r
�sizerrr�base64url_decodes

rcCs$t|t�r|�d�}tj|ddd�S)Nr)�,�:T)Z
separatorsZ	sort_keys)rr	r�json�dumps��stringrrr�json_encode!s

rcCst|t�r|�d�}t�|�S)Nr)rr	rr�loadsrrrr�json_decode's

r c@seZdZdS)�JWExceptionN)�__name__�
__module__�__qualname__rrrrr!-sr!cseZdZd�fdd�	Z�ZS)�InvalidJWAAlgorithmNcs(d}|r|d|7}tt|��|�dS)NzInvalid JWA Algorithm namez (%s))�superr%�__init__��self�message�msg��	__class__rrr'2szInvalidJWAAlgorithm.__init__)N)r"r#r$r'�
__classcell__rrr,rr%1sr%cs eZdZdZ�fdd�Z�ZS)�InvalidCEKeyLengthz�Invalid CEK Key Length.

    This exception is raised when a Content Encryption Key does not match
    the required length.
    cs d||f}tt|��|�dS)Nz&Expected key of length %d bits, got %d)r&r/r'�r)ZexpectedZobtainedr+r,rrr'@szInvalidCEKeyLength.__init__�r"r#r$�__doc__r'r.rrr,rr/9sr/cs"eZdZdZd�fdd�	Z�ZS)�InvalidJWEOperationz�Invalid JWS Object.

    This exception is raised when a requested operation cannot
    be execute due to unsatisfied conditions.
    Ncs:d}|r|}nd}|r&|dt|�7}tt|��|�dS�NzUnknown Operation Failurez {%s})�reprr&r3r'�r)r*�	exceptionr+r,rrr'LszInvalidJWEOperation.__init__)NNr1rrr,rr3Esr3cs eZdZdZ�fdd�Z�ZS)�InvalidJWEKeyTypez�Invalid JWE Key Type.

    This exception is raised when the provided JWK Key does not match
    the type required by the specified algorithm.
    cs d||f}tt|��|�dS)NzExpected key type %s, got %s)r&r8r'r0r,rrr'^szInvalidJWEKeyType.__init__r1rrr,rr8Wsr8cs eZdZdZ�fdd�Z�ZS)�InvalidJWEKeyLengthz�Invalid JWE Key Length.

    This exception is raised when the provided JWK Key does not match
    the length required by the specified algorithm.
    cs d||f}tt|��|�dS)Nz!Expected key of length %d, got %d)r&r9r'r0r,rrr'jszInvalidJWEKeyLength.__init__r1rrr,rr9csr9cs"eZdZdZd�fdd�	Z�ZS)�InvalidJWSERegOperationz�Invalid JWSE Header Registry Operation.

    This exception is raised when there is an error in trying to add a JW
    Signature or Encryption header to the Registry.
    Ncs:d}|r|}nd}|r&|dt|�7}tt|��|�dSr4)r5r&r:r'r6r,rrr'vsz InvalidJWSERegOperation.__init__)NNr1rrr,rr:osr:cs"eZdZdZd�fdd�	Z�ZS)�
JWKeyNotFoundz�The key needed to complete the operation was not found.

    This exception is raised when a JWKSet is used to perform
    some operation and the key required to successfully complete
    the operation is not found.
    Ncs"|r
|}nd}tt|��|�dS)Nz
Key Not Found)r&r;r'r(r,rrr'�szJWKeyNotFound.__init__)Nr1rrr,rr;�sr;Z	Parameterz*description mustprotect supported check_fnc@sFeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)�JWSEHeaderRegistryNcCs:|r&t|t�rt�|�|_q,td��ni|_t�|�dS)NzUnknown input type)r�dict�copy�deepcopy�	_registryr:rr')r)Z
init_registryrrrr'�s

zJWSEHeaderRegistry.__init__cCs<||jvrtd|��|j|}|jdur.dS|�|�SdS)Nz No header "%s" found in registryT)r@r:Zcheck_fn)r)�h�valueZparamrrr�check_header�s
�

zJWSEHeaderRegistry.check_headercCs|j�|�S�N)r@�__getitem__�r)�keyrrrrE�szJWSEHeaderRegistry.__getitem__cCs
|j��SrD)r@�__iter__�r)rrrrH�szJWSEHeaderRegistry.__iter__cCs2|j|js|j|jr"td��n|j�|�dS)Nz-Unable to delete protected or supported field)r@�mustprotect�	supportedr:�__delitem__rFrrrrL�s

�
zJWSEHeaderRegistry.__delitem__cCsP||jvrB|j|}|jr$td��n|jr:|js:td��n|j|=||j|<dS)Nz+Supported header already exists in registryz,Header specified should bea protected header)r@rKr:rJ)r)rAZjwse_header_param�prrr�__setitem__�s



zJWSEHeaderRegistry.__setitem__cCs
|j��SrD)r@�__len__rIrrrrO�szJWSEHeaderRegistry.__len__)N)
r"r#r$r'rCrErHrLrNrOrrrrr<�s
r<)r>r�base64rr�collectionsr�collections.abcrrrrr �	Exceptionr!r%r/r3r8r9r:r;ZJWSEHeaderParameterr<rrrr�<module>s(
�