Your IP : 18.118.166.45


Current Path : /opt/alt/python37/lib/python3.7/site-packages/jwt/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/jwt/__pycache__/api_jwt.cpython-37.pyc

B

�E�`��@s�ddlZddlmZddlmZmZddlmZmZddlm	Z	m
Z
mZmZm
Z
mZddlmZddlmZmZmZmZmZmZmZGd	d
�d
�Ze�ZejZejZejZdS)�N)�timegm)�Iterable�Mapping)�datetime�	timedelta)�Any�Dict�List�Optional�Type�Union�)�api_jws)�DecodeError�ExpiredSignatureError�ImmatureSignatureError�InvalidAudienceError�InvalidIssuedAtError�InvalidIssuerError�MissingRequiredClaimErrorc@s�eZdZd dd�Zeeeeee	effd�dd��Z
d!eeefeeeeee
ejed�d	d
�Zd"eee	eeeeefd�d
d�Zd#eee	eeeeefd�dd�Zd$dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)%�PyJWTNcCs|dkri}|��|�|_dS)N)�_get_default_options�options)�selfr�r�</opt/alt/python37/lib/python3.7/site-packages/jwt/api_jwt.py�__init__szPyJWT.__init__)�returncCsddddddgd�S)NT)�verify_signature�
verify_exp�
verify_nbf�
verify_iat�
verify_aud�
verify_iss�requirerrrrrrszPyJWT._get_default_options�HS256)�payload�key�	algorithm�headers�json_encoderrcCstt|t�std��|��}x0dD](}t|�|�t�r t||���||<q Wtj	|d|d��
d�}t�
|||||�S)NzJExpecting a mapping object, as JWT only supports JSON objects as payloads.)�exp�iat�nbf)�,�:)�
separators�clszutf-8)�
isinstancer�	TypeError�copy�getrr�utctimetuple�json�dumps�encoder)rr&r'r(r)r*Z
time_claimZjson_payloadrrrr9%s	

zPyJWT.encode�)�jwtr'�
algorithmsrrc

Ks
|dkrddi}n|�dd�|dsb|�dd�|�dd�|�dd�|�dd�|�dd�|drv|svtd	��tj|f|||d
�|��}yt�|d�}Wn.tk
r�}ztd|��Wdd}~XYnXt|t�s�td
��|j	|�}	|j
||	f|�||d<|S)NrTrFr r!r"r#z\It is required that you pass in a value for the "algorithms" argument when calling decode().)r'r<rr&zInvalid payload string: %sz-Invalid payload string: must be a json object)�
setdefaultrr�decode_completer7�loads�
ValueErrorr2�dictr�_validate_claims)
rr;r'r<r�kwargs�decodedr&�eZmerged_optionsrrrr>As8


zPyJWT.decode_completecKs|j||||f|�}|dS)Nr&)r>)rr;r'r<rrCrDrrr�decodeoszPyJWT.decodercKs�t|t�r|��}t|tttd�tf�s0td��|�||�t	t
�����}d|krj|drj|�
|||�d|kr�|dr�|�|||�d|kr�|dr�|�|||�|dr�|�||�|d	r�|�||�dS)
Nz,audience must be a string, iterable, or Noner,r!r-r r+rr#r")r2r�
total_seconds�bytes�str�typerr3�_validate_required_claimsrr�utcnowr6�
_validate_iat�
_validate_nbf�
_validate_exp�
_validate_iss�
_validate_aud)rr&r�audience�issuer�leewayrC�nowrrrrBzs 
zPyJWT._validate_claimscCs,x&|dD]}|�|�dkr
t|��q
WdS)Nr$)r5r)rr&rZclaimrrrrK�szPyJWT._validate_required_claimscCs2yt|d�Wntk
r,td��YnXdS)Nr,z)Issued At claim (iat) must be an integer.)�intr@r)rr&rUrTrrrrM�szPyJWT._validate_iatcCsFyt|d�}Wntk
r,td��YnX|||krBtd��dS)Nr-z*Not Before claim (nbf) must be an integer.z The token is not yet valid (nbf))rVr@rr)rr&rUrTr-rrrrN�szPyJWT._validate_nbfcCsFyt|d�}Wntk
r,td��YnX|||krBtd��dS)Nr+z/Expiration Time claim (exp) must be an integer.zSignature has expired)rVr@rr)rr&rUrTr+rrrrO�szPyJWT._validate_expcs�|dkrd|krdS|dk	r,d|kr,td��|dkrDd|krDtd��|d�t�t�r\�g�t�t�sntd��tdd��D��r�td��t|t�r�|g}t�fdd�|D��s�td��dS)N�audzInvalid audiencezInvalid claim format in tokencss|]}t|t�VqdS)N)r2rI)�.0�crrr�	<genexpr>�sz&PyJWT._validate_aud.<locals>.<genexpr>c3s|]}|�kVqdS)Nr)rXrW)�audience_claimsrrrZ�s)rrr2rI�list�any)rr&rRr)r[rrQ�s"


zPyJWT._validate_audcCs4|dkrdSd|krtd��|d|kr0td��dS)NZisszInvalid issuer)rr)rr&rSrrrrP�szPyJWT._validate_iss)N)r%NN)r:NN)r:NN)NNr)�__name__�
__module__�__qualname__r�staticmethodrrIr�boolr	rrr
rr7�JSONEncoderr9r>rFrBrKrMrNrOrQrPrrrrrs,
$"*
		r)r7�calendarr�collections.abcrrrr�typingrrr	r
rrr:r�
exceptionsrrrrrrrrZ_jwt_global_objr9r>rFrrrr�<module>s $I

?>