PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB` 3 ,[q9@s@dZddlmZmZddlZddlZddlZddlZddlZddl Z yddl m Z ddl m Z Wn,e k rddlmZ ddlm Z YnXy(ddlmZddlmZdd lmZWn8e k rddlmZddlmZdd lmZYnXy ddlZWn e k rddljZYnXd Zd Zejd ejZejd ZdZ ej!dZ"ej#ddkZ$e$rje%Z&e'Z(ne)Z&e%Z(dd6d7Z9Gd8d9d9e:Z;Gd:d;d;e<Z=dS)?z| oauthlib.common ~~~~~~~~~~~~~~ This module provides data structures and utilities common to all implementations of OAuth. )absolute_importunicode_literalsN)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|tr|jdn|}t||}t|tr6|jd}|S)Nzutf-8) isinstance unicode_typeencode_quote bytes_typedecode)sZsafer/usr/lib/python3.6/common.pyr@s    rcCs t|}t|tr|jd}|S)Nzutf-8)_unquoter rr)rrrrrJs  rcCs,t|}t|}t|tr|S|jdSdS)Nzutf-8)encode_params_utf8 _urlencoder r r)paramsZ utf8_params urlencodedrrrr Ts  r cCsPg}xF|D]>\}}|jt|tr*|jdn|t|tr@|jdn|fq 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)rZencodedkvrrrr]s  rcCsPg}xF|D]>\}}|jt|tr*|jdn|t|tr@|jdn|fq W|S)zfEnsures that all parameters in a list of 2-element tuples are decoded to unicode using UTF-8. zutf-8)rr rr)rZdecodedrrrrrdecode_params_utf8is  rz=&;:%+~,*@!()/?cCst|r.t|tk r.d}t|t|t|ftj|r@tdt rZt|trZ|jdn|}t j |dd}t |S)aDecode 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. zError 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 ValueErrorINVALID_HEX_PATTERNsearchPY3r r rurlparse parse_qslr)queryerrorrrrr urldecodexs  r(c Cst|tst|trsz!generate_token..)rjoinrange)lengthr:r)r:r;rgenerate_tokensr@cCsTddl}tjj}|j|tj|jdd}|j|j|j||d}t |d}|S)Nr)Zseconds)scopeZexpRS256zUTF-8) jwtdatetimeZutcnowrAZ timedeltaZ expires_inupdateclaimsr to_unicode)Z private_pemZrequestrCZnowrFtokenrrrgenerate_signed_tokens   rIcCsddl}|j||dgdS)NrrB)Z algorithms)rCr)Z public_pemrHrCrrrverify_signed_tokensrJcCs t||S)zGenerates an OAuth client_id OAuth 2 specify the format of client_id in https://tools.ietf.org/html/rfc6749#appendix-A. )r@)r?r:rrrgenerate_client_idsrKcCs2t|tr|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&rZ queryparamsrrradd_params_to_qss   rMFc CsFtj|\}}}}}}|r&t||}n t||}tj||||||fS)z5Add a list of two-tuples to the uri query components.)r$rMZ urlunparse) urirZfragmentZschZnetpathZparr&Zfrarrradd_params_to_uris   rPcCsLt|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)lenzipord)abresultr9yrrrsafe_string_equals!s rXUTF-8c st|tr|St|tr$t|dSt|dry t|Wn4tk rNYnJtk rnfdd|DSXt|dr|j}tfdd|DS|S)z:Convert a number of different types of objects to unicode.)encodingr)c3s|]}t|VqdS)N)rG)r8i)rZrrr<Bszto_unicode..r.c3s&|]\}}t|t|fVqdS)N)rG)r8rr)rZrrr<Gs)r r rr*r+r,r r.)datarZr)rZrrG3s      rGcsbeZdZdZiZddZddZfddZfdd Zdd d Z fd dZ fddZ Z S)CaseInsensitiveDictz3Basic case insensitive dict with strings only keys.cCs2tdd|D|_x|D]}||||<qWdS)Ncss|]}|j|fVqdS)N)lower)r8rrrrr<Ssz/CaseInsensitiveDict.__init__..)r+proxy)selfr\rrrr__init__Rs zCaseInsensitiveDict.__init__cCs|j|jkS)N)r^r_)r`rrrr __contains__Wsz CaseInsensitiveDict.__contains__cs.|j|j}tt|j||j|j=dS)N)r_r^superr] __delitem__)r`rkey) __class__rrrdZszCaseInsensitiveDict.__delitem__cs|j|j}tt|j|S)N)r_r^rcr] __getitem__)r`rre)rfrrrg_szCaseInsensitiveDict.__getitem__NcCs||kr||S|S)Nr)r`rdefaultrrrgetcszCaseInsensitiveDict.getcs$tt|j||||j|j<dS)N)rcr] __setitem__r_r^)r`rr)rfrrrjfszCaseInsensitiveDict.__setitem__cs8tt|j||x t||D]}||j|j<qWdS)N)rcr]rEr+r_r^)r`argskwargsr)rfrrrEjszCaseInsensitiveDict.update)N) __name__ __module__ __qualname____doc__r_rarbrdrgrirjrE __classcell__rr)rfrr]Ls    r]c@sNeZdZdZdddZddZd d Zed d Zed dZ eddZ 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. GETNutf-8csfdd}|||_|||_t||p*i|_|||_t|j|_g|_i|_dddddddddddddddddddddddddddd|_ |j j t t |j |j j t |jpg|j j |jdS)Ncsrt|S|S)N)rG)r9)rZrrsz"Request.__init__..)Z access_tokenZclientZ client_idZ client_secretcodeZextra_credentialsZ grant_typeZ redirect_uriZ refresh_tokenZ request_tokenZ response_typerAZscopesstaterHuserZtoken_type_hintZ response_modeZnonceZdisplaypromptrFZmax_ageZ ui_localesZ id_token_hintZ login_hintZ acr_values)rN http_methodr]headersbodyr0 decoded_bodyZ oauth_paramsZ validator_log_paramsrEr+r( uri_query)r`rNrzr|r{rZrr)rZrrasL      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 Z Authorizationz zF)r|r{copySANITIZE_PATTERNsubstrrNrz)r`r|r{rrr__repr__s zRequest.__repr__cCstj|jjS)N)r$rNr&)r`rrrrszRequest.uri_querycCs|js gStj|jdddS)NT)rZstrict_parsing)rr$r%)r`rrruri_query_paramss zRequest.uri_query_paramscCsTtjt}dd|jpg|jD}x|D]}||d7<q*Wdd|jDS)Ncss|]}|dVqdS)rNr)r8prrrr<sz+Request.duplicate_params..cSsg|]\}}|dkr|qS)rr)r8rcrrr sz,Request.duplicate_params..) collections defaultdictr4r}rr.)r`Z seen_keysZall_keysrrrrduplicate_paramss   zRequest.duplicate_params)rsNNrt) rmrnrorprarrpropertyrrrrrrrrrps  /  rr)r )F)rY)>rpZ __future__rrrrDZloggingresysr5Zsecretsrr ImportErrorZrandomrZurllibrrrrr rZ urllib.parser$parseZUNICODE_ASCII_CHARACTER_SETZCLIENT_ID_CHARACTER_SETcompile IGNORECASErr!Z always_safeZ getLoggerlog version_infor#rr bytesrZunicoderrrrr(r0r3r2r@rIrJrKrMrPrXrGr+r]objectrrrrrrsr              1     $