%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core18/2887/usr/lib/python3/dist-packages/oauthlib/__pycache__/
Upload File :
Create Path :
Current File : //snap/core18/2887/usr/lib/python3/dist-packages/oauthlib/__pycache__/common.cpython-36.pyc

3

%��Y�8�@s�dZddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
Z
y(ddlmZ
ddlmZddlmZWn8ek
r�ddlmZ
ddlmZddlmZYnXyddlZWnek
r�ddljZYnXdZdZejd	ej�Zejd
�ZdZejd�Ze	jdd
kZ e �r&e!Z"e#Z$ne%Z"e!Z$d9dd�Zdd�Zdd�Zdd�Z&dd�Z'e(e�e(d�BZ)dd�Z*dd�Z+dd�Z,d d!�Z-d"efd#d$�Z.d%d&�Z/d'd(�Z0d"efd)d*�Z1d+d,�Z2d:d.d/�Z3d0d1�Z4d;d3d4�Z5Gd5d6�d6e6�Z7Gd7d8�d8e8�Z9dS)<z|
oauthlib.common
~~~~~~~~~~~~~~

This module provides data structures and utilities common
to all implementations of OAuth.
�)�absolute_import�unicode_literalsN)�quote)�unquote)�	urlencodeZ>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789z_ !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}z&([^&;]*(?:password|token)[^=]*=)[^&;]+z&%[^0-9A-Fa-f]|%[0-9A-Fa-f][^0-9A-Fa-f]zAABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-Zoauthlib��/cCs:t|t�r|jd�n|}t||�}t|t�r6|jd�}|S)Nzutf-8)�
isinstance�unicode_type�encode�_quote�
bytes_type�decode)�sZsafe�r�1/usr/lib/python3/dist-packages/oauthlib/common.pyr;s



rcCs t|�}t|t�r|jd�}|S)Nzutf-8)�_unquoter	r
r)rrrrrEs

rcCs,t|�}t|�}t|t�r|S|jd�SdS)Nzutf-8)�encode_params_utf8�
_urlencoder	r
r)�paramsZutf8_params�
urlencodedrrrrOs

rcCsPg}xF|D]>\}}|jt|t�r*|jd�n|t|t�r@|jd�n|f�q
W|S)ziEnsures that all parameters in a list of 2-element tuples are encoded to
    bytestrings using UTF-8
    zutf-8)�appendr	r
r)rZencoded�k�vrrrrXs rcCsPg}xF|D]>\}}|jt|t�r*|jd�n|t|t�r@|jd�n|f�q
W|S)zfEnsures that all parameters in a list of 2-element tuples are decoded to
    unicode using UTF-8.
    zutf-8)rr	r
r)rZdecodedrrrrr�decode_params_utf8ds rz=&;:%+~,*@!()/?cCst|r.t|�tkr.d}t|t|�t|f��tj|�r@td��trZt|t�rZ|jd�n|}t	j
|dd�}t|�S)a�Decode a query string in x-www-form-urlencoded format into a sequence
    of two-element tuples.

    Unlike urlparse.parse_qsl(..., strict_parsing=True) urldecode will enforce
    correct formatting of the query string by validation. If validation fails
    a ValueError will be raised. urllib.parse_qsl will only raise errors if
    any of name-value pairs omits the equals sign.
    z�Error trying to decode a non urlencoded string. Found invalid characters: %s in the string: '%s'. Please ensure the request/response body is x-www-form-urlencoded.z%Invalid hex encoding in query string.zutf-8T)�keep_blank_values)�setr�
ValueError�INVALID_HEX_PATTERN�search�PY3r	r
r�urlparse�	parse_qslr)�query�errorrrrr�	urldecodess

r%cCs�t|t�st|t�r<yt|�}Wq�tk
r8d}Yq�Xnnt|d�r�yt|�Wn.tk
rjd}Yq�tk
r�d}Yq�Xtt|t�r�|j	�n|�}t
|�}nd}|S)a*Extract parameters and return them as a list of 2-tuples.

    Will successfully extract parameters from urlencoded query strings,
    dicts, or lists of 2-tuples. Empty strings/dicts/lists will return an
    empty list of parameters. Any other input will result in a return
    value of None.
    N�__iter__)r	r
r
r%r�hasattr�dict�	TypeError�list�itemsr)�rawrrrr�extract_params�s 


r-cCstttjd��t��S)a�Generate pseudorandom nonce that is unlikely to repeat.

    Per `section 3.3`_ of the OAuth 1 RFC 5849 spec.
    Per `section 3.2.1`_ of the MAC Access Authentication spec.

    A random 64-bit number is appended to the epoch timestamp for both
    randomness and to decrease the likelihood of collisions.

    .. _`section 3.2.1`: http://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-01#section-3.2.1
    .. _`section 3.3`: http://tools.ietf.org/html/rfc5849#section-3.3
    �@)r
�randomZgetrandbits�generate_timestamprrrr�generate_nonce�sr1cCstttj���S)aBGet seconds since epoch (UTC).

    Per `section 3.3`_ of the OAuth 1 RFC 5849 spec.
    Per `section 3.2.1`_ of the MAC Access Authentication spec.

    .. _`section 3.2.1`: http://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-01#section-3.2.1
    .. _`section 3.3`: http://tools.ietf.org/html/rfc5849#section-3.3
    )r
�int�timerrrrr0�s	r0�cs&tj��dj��fdd�t|�D��S)aXGenerates a non-guessable OAuth token

    OAuth (1 and 2) does not specify the format of tokens except that they
    should be strings of random characters. Tokens should not be guessable
    and entropy when generating the random characters is important. Which is
    why SystemRandom is used instead of the default random.choice method.
    �c3s|]}�j��VqdS)N)Zchoice)�.0�x)�chars�randrr�	<genexpr>�sz!generate_token.<locals>.<genexpr>)r/ZSystemRandom�join�range)�lengthr8r)r8r9r�generate_token�sr>cCsTddl}tjj�}|j|tj|jd�d�}|j|j�|j||d�}t	|d�}|S)Nr)Zseconds)�scopeZexp�RS256zUTF-8)
�jwt�datetimeZutcnowr?Z	timedeltaZ
expires_in�update�claimsr�
to_unicode)Zprivate_pemZrequestrAZnowrD�tokenrrr�generate_signed_token�s

rGcCsddl}|j||dgd�S)Nrr@)Z
algorithms)rAr)Z
public_pemrFrArrr�verify_signed_token�srHcCs
t||�S)z�Generates an OAuth client_id

    OAuth 2 specify the format of client_id in
    http://tools.ietf.org/html/rfc6749#appendix-A.
    )r>)r=r8rrr�generate_client_idsrIcCs2t|t�r|j�}tj|dd�}|j|�t|�S)z)Extend a query with a list of two-tuples.T)r)r	r(r+r!r"�extendr)r#rZqueryparamsrrr�add_params_to_qs	s


rKFc	CsFtj|�\}}}}}}|r&t||�}n
t||�}tj||||||f�S)z5Add a list of two-tuples to the uri query components.)r!rKZ
urlunparse)	�urirZfragmentZschZnet�pathZparr#Zfrarrr�add_params_to_uris

rNcCsLt|�t|�krdSd}x*t||�D]\}}|t|�t|�AO}q$W|dkS)a Near-constant time string comparison.

    Used in order to avoid timing attacks on sensitive information such
    as secret keys during request verification (`rootLabs`_).

    .. _`rootLabs`: http://rdist.root.org/2010/01/07/timing-independent-array-comparison/

    Fr)�len�zip�ord)�a�b�resultr7�yrrr�safe_string_equalss	rV�UTF-8cs�t|t�r|St|t�r$t|�d�St|d�r�yt|�Wn4tk
rNYnJtk
rn�fdd�|D�SXt|d�r�|j�}t�fdd�|D��S|S)z:Convert a number of different types of objects to unicode.)�encodingr&c3s|]}t|��VqdS)N)rE)r6�i)rXrrr:=szto_unicode.<locals>.<genexpr>r+c3s&|]\}}t|��t|��fVqdS)N)rE)r6rr)rXrrr:Bs)r	r
r
r'r(r)rr+)�datarXr)rXrrE.s



rEcsbeZdZdZiZdd�Zdd�Z�fdd�Z�fdd	�Zddd�Z	�fd
d�Z
�fdd�Z�ZS)�CaseInsensitiveDictz3Basic case insensitive dict with strings only keys.cCs2tdd�|D��|_x|D]}||||<qWdS)Ncss|]}|j�|fVqdS)N)�lower)r6rrrrr:Nsz/CaseInsensitiveDict.__init__.<locals>.<genexpr>)r(�proxy)�selfrZrrrr�__init__Ms
zCaseInsensitiveDict.__init__cCs|j�|jkS)N)r\r])r^rrrr�__contains__Rsz CaseInsensitiveDict.__contains__cs.|j|j�}tt|�j|�|j|j�=dS)N)r]r\�superr[�__delitem__)r^r�key)�	__class__rrrbUszCaseInsensitiveDict.__delitem__cs|j|j�}tt|�j|�S)N)r]r\rar[�__getitem__)r^rrc)rdrrreZszCaseInsensitiveDict.__getitem__NcCs||kr||S|S)Nr)r^r�defaultrrr�get^szCaseInsensitiveDict.getcs$tt|�j||�||j|j�<dS)N)rar[�__setitem__r]r\)r^rr)rdrrrhaszCaseInsensitiveDict.__setitem__cs8tt|�j||�x t||�D]}||j|j�<qWdS)N)rar[rCr(r]r\)r^�args�kwargsr)rdrrrCeszCaseInsensitiveDict.update)N)
�__name__�
__module__�__qualname__�__doc__r]r_r`rbrergrhrC�
__classcell__rr)rdrr[Gs
r[c@sNeZdZdZddd�Zdd�Zd	d
�Zedd��Zed
d��Z	edd��Z
dS)�Requesta:A malleable representation of a signable HTTP request.

    Body argument may contain any data, but parameters will only be decoded if
    they are one of:

    * urlencoded query string
    * dict
    * list of 2-tuples

    Anything else will be treated as raw body data to be passed through
    unmolested.
    �GETN�utf-8cs��fdd�}||�|_||�|_t||p*i��|_||�|_t|j�|_g|_i|_dddddddddddddddddddddddddddd�|_	|j	j
tt|j
���|j	j
t|jp�g��|j	j
|j�dS)Ncs�rt|��S|S)N)rE)r7)rXrr�<lambda>}sz"Request.__init__.<locals>.<lambda>)Zaccess_tokenZclientZ	client_idZ
client_secret�codeZextra_credentialsZ
grant_typeZredirect_uriZ
refresh_tokenZ
request_tokenZ
response_typer?Zscopes�staterF�userZtoken_type_hintZ
response_modeZnonceZdisplay�promptrDZmax_ageZ
ui_localesZ
id_token_hintZ
login_hintZ
acr_values)rL�http_methodr[�headers�bodyr-�decoded_bodyZoauth_paramsZ
validator_log�_paramsrCr(r%�	uri_query)r^rLrxrzryrXrr)rXrr_zsL



zRequest.__init__cCs ||jkr|j|St|��dS)N)r|�AttributeError)r^�namerrr�__getattr__�s

zRequest.__getattr__cCsH|j}|jj�}|r$tjdt|��}d|kr4d|d<d|j|j||fS)Nz<SANITIZED>Z
Authorizationz<SANITIZED>zF<oauthlib.Request url="%s", http_method="%s", headers="%s", body="%s">)rzry�copy�SANITIZE_PATTERN�sub�strrLrx)r^rzryrrr�__repr__�s
zRequest.__repr__cCstj|j�jS)N)r!rLr#)r^rrrr}�szRequest.uri_querycCs|js
gStj|jddd�S)NT)rZstrict_parsing)r}r!r")r^rrr�uri_query_params�s
zRequest.uri_query_paramscCsTtjt�}dd�|jpg|jD�}x|D]}||d7<q*Wdd�|j�D�S)Ncss|]}|dVqdS)rNr)r6�prrrr:�sz+Request.duplicate_params.<locals>.<genexpr>�cSsg|]\}}|dkr|�qS)r�r)r6r�crrr�
<listcomp>�sz,Request.duplicate_params.<locals>.<listcomp>)�collections�defaultdictr2r{r�r+)r^Z	seen_keysZall_keysrrrr�duplicate_params�s

zRequest.duplicate_params)rqNNrr)rkrlrmrnr_r�r��propertyr}r�r�rrrrrpks

/
rp)r)F)rW):rnZ
__future__rrr�rBZloggingr/�re�sysr3Zurllibrrrrrr�ImportErrorZurllib.parser!�parseZUNICODE_ASCII_CHARACTER_SETZCLIENT_ID_CHARACTER_SET�compile�
IGNORECASEr�rZalways_safeZ	getLogger�log�version_infor r�r
�bytesr
Zunicoderrrrr%r-r1r0r>rGrHrIrKrNrVrEr(r[�objectrprrrr�<module>sh




	1		


$

Zerion Mini Shell 1.0