%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core20/current/lib/python3/dist-packages/oauthlib/__pycache__/
Upload File :
Create Path :
Current File : //snap/core20/current/lib/python3/dist-packages/oauthlib/__pycache__/common.cpython-38.pyc

U

��I]�9�@sFdZddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
mZzddlm
Z
ddlmZWn,ek
r�ddlmZ
ddlmZYnXz(dd	lmZdd
lmZddlmZWn8ek
r�dd	lmZdd
lmZddlmZYnXzddlZWn"ek
�r*ddlmZYnXdZd
Ze�dej�Z e�d�Z!dZ"e�#d�Z$ej%ddkZ&e&�rte'Z(ne)Z(d>dd�Zdd�Zdd�Zdd�Z*dd�Z+e,e"�e,d�BZ-dd �Z.d!d"�Z/d#d$�Z0d%d&�Z1d'efd(d)�Z2d*d+�Z3d,d-�Z4d'efd.d/�Z5d0d1�Z6d?d3d4�Z7d5d6�Z8d@d8d9�Z9Gd:d;�d;e:�Z;Gd<d=�d=e<�Z=dS)Az|
oauthlib.common
~~~~~~~~~~~~~~

This module provides data structures and utilities common
to all implementations of OAuth.
�)�absolute_import�unicode_literalsN�)�	get_debug)�randbits)�SystemRandom)�getrandbits)�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|�d�n|}t||�}t|t�r6|�d�}|S�N�utf-8)�
isinstance�unicode_type�encode�_quote�bytes�decode)�sZsafe�r�1/usr/lib/python3/dist-packages/oauthlib/common.pyr	?s



r	cCs t|�}t|t�r|�d�}|Sr)�_unquoterrr)rrrrr
Is

r
cCs,t|�}t|�}t|t�r|S|�d�SdSr)�encode_params_utf8�
_urlencoderrr)�paramsZutf8_params�
urlencodedrrrrSs

rcCsLg}|D]>\}}|�t|t�r(|�d�n|t|t�r>|�d�n|f�q|S)ziEnsures that all parameters in a list of 2-element tuples are encoded to
    bytestrings using UTF-8
    r)�appendrrr)rZencoded�k�vrrrr\s�rcCsLg}|D]>\}}|�t|t�r(|�d�n|t|t�r>|�d�n|f�q|S)zfEnsures that all parameters in a list of 2-element tuples are decoded to
    unicode using UTF-8.
    r)rrrr)rZdecodedrr rrr�decode_params_utf8hs�r!z=&;:%+~,*@!()/?'$cCsp|r,t|�tks,d}t|t|�t|f��t�|�r>td��tsVt|t�rV|�d�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.rT��keep_blank_values)�setr�
ValueError�INVALID_HEX_PATTERN�search�PY3rrr�urlparse�	parse_qslr!)�query�errorrrrr�	urldecodews

����r-cCs�t|ttf�r6zt|�}Wq�tk
r2d}Yq�Xnnt|d�r�zt|�Wn.tk
rdd}Yq�tk
rzd}Yq�Xtt|t�r�|�	�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__)rrrr-r%�hasattr�dict�	TypeError�list�itemsr!)�rawrrrr�extract_params�s 


r5cCstttd��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`: https://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-01#section-3.2.1
    .. _`section 3.3`: https://tools.ietf.org/html/rfc5849#section-3.3
    �@)rr�generate_timestamprrrr�generate_nonce�sr8cCsttt����S)aDGet 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`: https://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-01#section-3.2.1
    .. _`section 3.3`: https://tools.ietf.org/html/rfc5849#section-3.3
    )r�int�timerrrrr7�s	r7�cs$t��d���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|]}����VqdS�N)Zchoice)�.0�x��charsZrandrr�	<genexpr>�sz!generate_token.<locals>.<genexpr>)r�join�range�ZlengthrArr@r�generate_token�srFcCsTddl}tj��}|j|tj|jd�d�}|�|j�|�||d�}t	|d�}|S)Nr)Zseconds)�scopeZexp�RS256�UTF-8)
�jwt�datetimeZutcnowrGZ	timedeltaZ
expires_in�update�claimsr�
to_unicode)Zprivate_pemZrequestrJZnowrM�tokenrrr�generate_signed_token�s
�
rPcCsddl}|j||dgd�S)NrrH)Z
algorithms)rJr)Z
public_pemrOrJrrr�verify_signed_token�srQcCs
t||�S)z�Generates an OAuth client_id

    OAuth 2 specify the format of client_id in
    https://tools.ietf.org/html/rfc6749#appendix-A.
    )rFrErrr�generate_client_idsrRcCs2t|t�r|��}tj|dd�}|�|�t|�S)z)Extend a query with a list of two-tuples.Tr")rr0r3r)r*�extendr)r+rZqueryparamsrrr�add_params_to_qs
s


rTFc	CsFt�|�\}}}}}}|r&t||�}n
t||�}t�||||||f�S)z5Add a list of two-tuples to the uri query components.)r)rTZ
urlunparse)	�urirZfragmentZschZnet�pathZparr+Zfrarrr�add_params_to_uris

rWcCsHt|�t|�krdSd}t||�D]\}}|t|�t|�AO}q"|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�resultr?�yrrr�safe_string_equals s	r_rIcs�t|t�r|St|t�r$t|�d�St|d�r�zt|�Wn8tk
rNYnNtk
rr�fdd�|D�YSXt|d�r�|��}t�fdd�|D��S|S)z:Convert a number of different types of objects to unicode.��encodingr.c3s|]}t|��VqdSr=�rN)r>�ir`rrrBAszto_unicode.<locals>.<genexpr>r3c3s&|]\}}t|��t|��fVqdSr=rb)r>rr r`rrrBFs)rrrr/r0r1r%r3)�datararr`rrN2s



rNcsbeZdZdZiZdd�Zdd�Z�fdd�Z�fdd	�Zddd�Z	�fd
d�Z
�fdd�Z�ZS)�CaseInsensitiveDictz3Basic case insensitive dict with strings only keys.cCs.tdd�|D��|_|D]}||||<qdS)Ncss|]}|��|fVqdSr=)�lower)r>rrrrrBRsz/CaseInsensitiveDict.__init__.<locals>.<genexpr>)r0�proxy)�selfrdrrrr�__init__QszCaseInsensitiveDict.__init__cCs|��|jkSr=)rfrg)rhrrrr�__contains__Vsz CaseInsensitiveDict.__contains__cs.|j|��}tt|��|�|j|��=dSr=)rgrf�superre�__delitem__�rhr�key��	__class__rrrlYszCaseInsensitiveDict.__delitem__cs|j|��}tt|��|�Sr=)rgrfrkre�__getitem__rmrorrrq^szCaseInsensitiveDict.__getitem__NcCs||kr||S|Sr=r)rhr�defaultrrr�getbszCaseInsensitiveDict.getcs$tt|��||�||j|��<dSr=)rkre�__setitem__rgrf)rhrr rorrrteszCaseInsensitiveDict.__setitem__cs4tt|�j||�t||�D]}||j|��<qdSr=)rkrerLr0rgrf)rh�args�kwargsrrorrrLiszCaseInsensitiveDict.update)N)
�__name__�
__module__�__qualname__�__doc__rgrirjrlrqrsrtrL�
__classcell__rrrorreKs
rec@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.
    �GETNrcs��fdd�}||�|_||�|_t||p*i��|_||�|_t|j�|_g|_i|_ddddddddddddddddddddddddddddddd�|_	|j	�
tt|j
���|j	�
t|jp�g��dS)Ncs�rt|��S|Sr=rb)r?r`rr�<lambda>��z"Request.__init__.<locals>.<lambda>)Zaccess_tokenZclientZ	client_idZ
client_secret�codeZcode_challengeZcode_challenge_methodZ
code_verifierZextra_credentialsZ
grant_typeZredirect_uriZ
refresh_tokenZ
request_tokenZ
response_typerGZscopes�staterO�userZtoken_type_hintZ
response_modeZnonceZdisplay�promptrMZmax_ageZ
ui_localesZ
id_token_hintZ
login_hintZ
acr_values)rU�http_methodre�headers�bodyr5�decoded_bodyZoauth_paramsZ
validator_log�_paramsrLr0r-�	uri_query)rhrUr�r�r�rarrr`rri~sR


�"zRequest.__init__cCs ||jkr|j|St|��dSr=)r��AttributeError)rh�namerrr�__getattr__�s

zRequest.__getattr__cCsRt�s
dS|j}|j��}|r.t�dt|��}d|kr>d|d<d|j|j||fS)Nz<oauthlib.Request SANITIZED>z<SANITIZED>Z
Authorizationz<SANITIZED>zF<oauthlib.Request url="%s", http_method="%s", headers="%s", body="%s">)	rr�r��copy�SANITIZE_PATTERN�sub�strrUr�)rhr�r�rrr�__repr__�s
�zRequest.__repr__cCst�|j�jSr=)r)rUr+�rhrrrr��szRequest.uri_querycCs|js
gStj|jddd�S)NT)r#Zstrict_parsing)r�r)r*r�rrr�uri_query_params�s

�zRequest.uri_query_paramscCsPt�t�}dd�|jpg|jD�}|D]}||d7<q(dd�|��D�S)Ncss|]}|dVqdS)rNr)r>�prrrrB�s�z+Request.duplicate_params.<locals>.<genexpr>rcSsg|]\}}|dkr|�qS)rr)r>r�crrr�
<listcomp>�sz,Request.duplicate_params.<locals>.<listcomp>)�collections�defaultdictr9r�r�r3)rhZ	seen_keysZall_keysrrrr�duplicate_params�s
�zRequest.duplicate_params)r}NNr)rwrxryrzrir�r��propertyr�r�r�rrrrr|os
�
2

r|)r
)F)rI)>rzZ
__future__rrr�rKZlogging�re�sysr:r<rZsecretsrr�ImportErrorZrandomrZurllibr	rr
rrrZurllib.parser)�parseZUNICODE_ASCII_CHARACTER_SETZCLIENT_ID_CHARACTER_SET�compile�
IGNORECASEr�r&Zalways_safeZ	getLogger�log�version_infor(r�rZunicoderr!r$rr-r5r8r7rFrPrQrRrTrWr_rNr0re�objectr|rrrr�<module>sp




	1		


$

Zerion Mini Shell 1.0