Ë
    ,Œ:jí.  ã                   ó2  — d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ ddl	m
Z
 ddlmZmZmZ ddlmZmZmZ ej&                  rd dl mZ  G d	„ d
«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ dej4                  «      Zy)é    N)Ú	b64encode)Úparse_http_listé   )ÚProtocolError)ÚCookiesÚRequestÚResponse)Úto_bytesÚto_strÚunquote)Ú_Hashc                   ó¦   — e Zd ZdZdZdZdedej                  ee	df   fd„Z
dedej                  ee	df   fd„Zdedej                  ee	f   fd„Zy)	ÚAuthaô  
    Base class for all authentication schemes.

    To implement a custom authentication scheme, subclass `Auth` and override
    the `.auth_flow()` method.

    If the authentication scheme does I/O such as disk access or network calls, or uses
    synchronization primitives such as locks, you should override `.sync_auth_flow()`
    and/or `.async_auth_flow()` instead of `.auth_flow()` to provide specialized
    implementations that will be used by `Client` and `AsyncClient` respectively.
    FÚrequestÚreturnNc              #   ó   K  — |–— y­w)a  
        Execute the authentication flow.

        To dispatch a request, `yield` it:

        ```
        yield request
        ```

        The client will `.send()` the response back into the flow generator. You can
        access it like so:

        ```
        response = yield request
        ```

        A `return` (or reaching the end of the generator) will result in the
        client returning the last response obtained from the server.

        You can dispatch as many requests as is necessary.
        N© ©Úselfr   s     úM/var/www/html/tokenscope/api/venv/lib/python3.12/site-packages/httpx/_auth.pyÚ	auth_flowzAuth.auth_flow!   s   è ø€ ð, ‹ùs   ‚c              #   ó   K  — | j                   r|j                  «        | j                  |«      }t        |«      }	 |–—}| j                  r|j                  «        	 |j                  |«      }Œ3# t        $ r Y yw xY w­w)zè
        Execute the authentication flow synchronously.

        By default, this defers to `.auth_flow()`. You should override this method
        when the authentication scheme does I/O and/or uses concurrency primitives.
        N)Úrequires_request_bodyÚreadr   ÚnextÚrequires_response_bodyÚsendÚStopIteration©r   r   ÚflowÚresponses       r   Úsync_auth_flowzAuth.sync_auth_flow9   sx   è ø€ ð ×%Ò%Ø�L‰LŒNà�~‰~˜gÓ&ˆÜ�t“*ˆàØ$‘}ˆHØ×*Ò*Ø—‘”ðØŸ)™) HÓ-�ð øô !ò Ùðüs*   ‚AA>ÁA/ Á.A>Á/	A;Á8A>Á:A;Á;A>c                ó*  K  — | j                   r|j                  «       ƒ d{  –—†  | j                  |«      }t        |«      }	 |­–—}| j                  r|j                  «       ƒ d{  –—†  	 |j                  |«      }Œ<7 Œ]7 Œ# t        $ r Y yw xY w­w)zé
        Execute the authentication flow asynchronously.

        By default, this defers to `.auth_flow()`. You should override this method
        when the authentication scheme does I/O and/or uses concurrency primitives.
        N)r   Úareadr   r   r   r   r   r   s       r   Úasync_auth_flowzAuth.async_auth_flowR   s�   è ø€ ð ×%Ò%Ø—-‘-“/×!Ð!à�~‰~˜gÓ&ˆÜ�t“*ˆàØ$’}ˆHØ×*Ò*Ø—n‘nÓ&×&Ð&ðØŸ)™) HÓ-�ð ð "øð 'ùô !ò ÙðüsF   ‚ B¢B £ABÁ(BÁ)BÁ.B Á?BÂBÂ	BÂBÂBÂB)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   ÚtypingÚ	Generatorr	   r   r"   ÚAsyncGeneratorr%   r   ó    r   r   r      s‡   „ ñ
ð "ÐØ"Ðð ð ¨V×-=Ñ-=¸gÀxÐQUÐ>UÑ-Vó ð0Øðà	×	Ñ	˜' 8¨TÐ1Ñ	2óð2Øðà	×	Ñ	˜w¨Ð0Ñ	1ôr-   r   c                   óp   — e Zd ZdZdej
                  egef   ddfd„Zdedej                  ee	df   fd„Z
y)ÚFunctionAuthz‘
    Allows the 'auth' argument to be passed as a simple callable function,
    that takes the request, and returns a new, modified request.
    Úfuncr   Nc                 ó   — || _         y ©N©Ú_func)r   r0   s     r   Ú__init__zFunctionAuth.__init__r   s	   € Øˆ�
r-   r   c              #   ó2   K  — | j                  |«      –— y ­wr2   r3   r   s     r   r   zFunctionAuth.auth_flowu   s   è ø€ Ø�j‰j˜Ó!Ó!ùs   ‚)r&   r'   r(   r)   r*   ÚCallabler   r5   r+   r	   r   r   r-   r   r/   r/   l   sP   „ ñð
˜VŸ_™_¨g¨Y¸Ð-?Ñ@ð ÀTó ð" ð "¨V×-=Ñ-=¸gÀxÐQUÐ>UÑ-Vô "r-   r/   c                   óÜ   — e Zd ZdZdej
                  eef   dej
                  eef   fd„Zde	dej                  e	edf   fd„Zdej
                  eef   dej
                  eef   defd	„Zy)
Ú	BasicAuthzy
    Allows the 'auth' argument to be passed as a (username, password) pair,
    and uses HTTP Basic authentication.
    ÚusernameÚpasswordc                 ó2   — | j                  ||«      | _        y r2   )Ú_build_auth_headerÚ_auth_header©r   r:   r;   s      r   r5   zBasicAuth.__init__   s   € ð !×3Ñ3°H¸hÓGˆÕr-   r   r   Nc              #   óF   K  — | j                   |j                  d<   |–— y ­w)NÚAuthorization)r>   Úheadersr   s     r   r   zBasicAuth.auth_flow„   s   è ø€ Ø+/×+<Ñ+<ˆ�‰˜Ñ(Ø‹ùs   ‚!c                 óˆ   — dj                  t        |«      t        |«      f«      }t        |«      j                  «       }d|› �S ©Nó   :zBasic ©Újoinr
   r   Údecode©r   r:   r;   ÚuserpassÚtokens        r   r=   zBasicAuth._build_auth_headerˆ   óA   € ð —9‘9œh xÓ0´(¸8Ó2DÐEÓFˆÜ˜(Ó#×*Ñ*Ó,ˆØ˜�wÐÐr-   )r&   r'   r(   r)   r*   ÚUnionÚstrÚbytesr5   r   r+   r	   r   r=   r   r-   r   r9   r9   y   s–   „ ñð
HØŸ™ S¨% ZÑ0ðHØ<B¿L¹LÈÈeÈÑ<TóHð
 ð ¨V×-=Ñ-=¸gÀxÐQUÐ>UÑ-Vó ð ØŸ™ S¨% ZÑ0ð Ø<B¿L¹LÈÈeÈÑ<Tð à	ô r-   r9   c                   ó¸   — e Zd ZdZddej
                  e   fd„Zdedej                  ee
df   fd„Zdej                  eef   d	ej                  eef   defd
„Zy)Ú	NetRCAuthzT
    Use a 'netrc' file to lookup basic auth credentials based on the url host.
    NÚfilec                 ó8   — dd l }|j                  |«      | _        y )Nr   )ÚnetrcÚ_netrc_info)r   rR   rT   s      r   r5   zNetRCAuth.__init__•   s   € ó 	à Ÿ;™; tÓ,ˆÕr-   r   r   c              #   óÖ   K  — | j                   j                  |j                  j                  «      }|�|d   s|–— y | j	                  |d   |d   ¬«      |j
                  d<   |–— y ­w)Né   r   )r:   r;   rA   )rU   ÚauthenticatorsÚurlÚhostr=   rB   )r   r   Ú	auth_infos      r   r   zNetRCAuth.auth_flowœ   sl   è ø€ Ø×$Ñ$×3Ñ3°G·K±K×4DÑ4DÓEˆ	ØÐ I¨a¢Là‹Mð 04×/FÑ/FØ" 1™°	¸!±ð 0Gó 0ˆG�O‰O˜OÑ,ð ‹Mùs   ‚A'A)r:   r;   c                 óˆ   — dj                  t        |«      t        |«      f«      }t        |«      j                  «       }d|› �S rD   rF   rI   s        r   r=   zNetRCAuth._build_auth_header¨   rL   r-   r2   )r&   r'   r(   r)   r*   ÚOptionalrN   r5   r   r+   r	   r   rM   rO   r=   r   r-   r   rQ   rQ   �   sy   „ ññ-˜VŸ_™_¨SÑ1ó -ð
 ð 
¨V×-=Ñ-=¸gÀxÐQUÐ>UÑ-Vó 
ð ØŸ™ S¨% ZÑ0ð Ø<B¿L¹LÈÈeÈÑ<Tð à	ô r-   rQ   c            	       óB  — e Zd ZU ej                  ej                  ej
                  ej
                  ej                  ej                  ej                  ej                  dœZe	j                  ee	j                  egdf   f   ed<   de	j                  eef   de	j                  eef   ddfd„Zd	ede	j$                  eedf   fd
„Zd	edededdfd„Zd	edddefd„Zdededefd„Zde	j                  eef   defd„Zde	j4                  e   d	ede	j4                  e   fd„Zy)Ú
DigestAuth)ÚMD5zMD5-SESSÚSHAzSHA-SESSzSHA-256zSHA-256-SESSzSHA-512zSHA-512-SESSr   Ú_ALGORITHM_TO_HASH_FUNCTIONr:   r;   r   Nc                 ó`   — t        |«      | _        t        |«      | _        d | _        d| _        y )Nr   )r
   Ú	_usernameÚ	_passwordÚ_last_challengeÚ_nonce_countr?   s      r   r5   zDigestAuth.__init__¼   s,   € ô " (Ó+ˆŒÜ! (Ó+ˆŒØFJˆÔØˆÕr-   r   c              #   ó8  K  — | j                   r)| j                  || j                   «      |j                  d<   |–—}|j                  dk7  sd|j                  vry |j                  j	                  d«      D ]#  }|j                  «       j                  d«      sŒ# n y | j                  |||«      | _         d| _        | j                  || j                   «      |j                  d<   |j                  r%t        |j                  «      j                  |¬«       |–— y ­w)NrA   i‘  zwww-authenticatezdigest r   ©r   )rf   r=   rB   Ústatus_codeÚget_listÚlowerÚ
startswithÚ_parse_challengerg   Úcookiesr   Úset_cookie_header)r   r   r!   Úauth_headers       r   r   zDigestAuth.auth_flowÄ   s  è ø€ Ø×ÒØ/3×/FÑ/FØ˜×-Ñ-ó0ˆG�O‰O˜OÑ,ð !‘=ˆà×Ñ 3Ò&Ð*<ÀH×DTÑDTÑ*Tð à#×+Ñ+×4Ñ4Ð5GÓHò 	ˆKØ× Ñ Ó"×-Ñ-¨iÕ8Ùð	ð à#×4Ñ4°W¸hÈÓTˆÔØˆÔà+/×+BÑ+BØ�T×)Ñ)ó,
ˆ�‰˜Ñ(ð ×ÒÜ�H×$Ñ$Ó%×7Ñ7ÀÐ7ÔHØ‹ùs   ‚BDÂBDr!   rq   Ú_DigestAuthChallengec                 ó  — |j                  d«      \  }}}|j                  «       dk(  sJ ‚i }t        |«      D ]3  }|j                  «       j	                  dd«      \  }	}
t        |
«      ||	<   Œ5 	 |d   j                  «       }|d   j                  «       }|j                  dd«      }d	|v r|d	   j                  «       nd
}d|v r|d   j                  «       nd
}t        |||||¬«      S # t        $ r}d}t        ||¬«      |‚d
}~ww xY w)zÁ
        Returns a challenge from a Digest WWW-Authenticate header.
        These take the form of:
        `Digest realm="realm@host.com",qop="auth,auth-int",nonce="abc",opaque="xyz"`
        ú Údigestú=r   ÚrealmÚnonceÚ	algorithmr`   ÚopaqueNÚqop)rw   rx   ry   rz   r{   z(Malformed Digest WWW-Authenticate headerri   )Ú	partitionrl   r   ÚstripÚsplitr   ÚencodeÚgetrr   ÚKeyErrorr   )r   r   r!   rq   ÚschemeÚ_ÚfieldsÚheader_dictÚfieldÚkeyÚvaluerw   rx   ry   rz   r{   ÚexcÚmessages                     r   rn   zDigestAuth._parse_challengeã   s*  € ð (×1Ñ1°#Ó6Ñˆ��6ð �|‰|‹~ Ò)Ð)Ð)à-/ˆÜ$ VÓ,ò 	.ˆEØŸ™›×,Ñ,¨S°!Ó4‰JˆC�Ü& u›~ˆK˜Òð	.ð	CØ Ñ(×/Ñ/Ó1ˆEØ Ñ(×/Ñ/Ó1ˆEØ#Ÿ™¨°UÓ;ˆIØ7?À;Ñ7N�[ Ñ*×1Ñ1Ô3ÐTXˆFØ16¸+Ñ1E�+˜eÑ$×+Ñ+Ô-È4ˆCÜ'Ø 5°IÀfÐRUôð øô ò 	CØ@ˆGÜ °Ô9¸sÐBûð	Cús   Á/A9C) Ã)	DÃ2DÄDÚ	challengec           
      óx  ‡— | j                   |j                  j                  «          Šdt        dt        fˆfd„}dj	                  | j
                  |j                  | j                  f«      }|j                  j                  }dj	                  |j                  j                  «       |f«      } ||«      }d| j                  z  }| j                  | j                  |j                  «      }	| xj                  dz  c_         ||«      }
|j                  j                  «       j!                  d«      r$ |dj	                  |
|j                  |	f«      «      }
| j#                  |j$                  |¬«      }|€|
|j                  |g}n|j                  ||	||g}dj	                  |«      }| j
                  |j                  |j                  | |dj	                  |
|f«      «      |j                  j                  «       d	œ}|j&                  r|j&                  |d
<   |rd|d<   ||d<   |	|d<   d| j)                  |«      z   S )NÚdatar   c                 óL   •—  ‰| «      j                  «       j                  «       S r2   )Ú	hexdigestr   )r�   Ú	hash_funcs    €r   ru   z-DigestAuth._build_auth_header.<locals>.digest  s   ø€ Ù˜T“?×,Ñ,Ó.×5Ñ5Ó7Ð7r-   rE   s   %08xr   z-sessri   )r:   rw   rx   Úurir!   ry   rz   ó   authr{   ÚncÚcnoncezDigest )rb   ry   ÚupperrO   rG   rd   rw   re   rY   Úraw_pathÚmethodr   rg   Ú_get_client_noncerx   rl   ÚendswithÚ_resolve_qopr{   rz   Ú_get_header_value)r   r   r‹   ru   ÚA1ÚpathÚA2ÚHA2Únc_valuer”   ÚHA1r{   Údigest_dataÚ
key_digestÚformat_argsr�   s                  @r   r=   zDigestAuth._build_auth_header  sþ  ø€ ð ×4Ñ4°Y×5HÑ5H×5NÑ5NÓ5PÑQˆ	ð	8œð 	8¤5õ 	8ð �Y‰Y˜Ÿ™¨	¯©¸¿¹ÐHÓIˆà�{‰{×#Ñ#ˆØ�Y‰Y˜Ÿ™×-Ñ-Ó/°Ð6Ó7ˆá�R‹jˆà˜T×.Ñ.Ñ.ˆØ×'Ñ'¨×(9Ñ(9¸9¿?¹?ÓKˆØ×Ò˜QÑÕá�R‹jˆØ×Ñ×$Ñ$Ó&×/Ñ/°Ô8Ù˜Ÿ™ C¨¯©¸&Ð#AÓBÓCˆCà×Ñ 	§¡°wÐÓ?ˆØˆ;Ø 	§¡°Ð5‰Kà$Ÿ?™?¨H°f¸cÀ3ÐGˆKØ—Y‘Y˜{Ó+ˆ
ð Ÿ™Ø—_‘_Ø—_‘_ØÙ˜tŸy™y¨#¨zÐ):Ó;Ó<Ø"×,Ñ,×3Ñ3Ó5ñ
ˆð ×ÒØ$-×$4Ñ$4ˆK˜Ñ!ÙØ!(ˆK˜ÑØ (ˆK˜ÑØ$*ˆK˜Ñ!à˜4×1Ñ1°+Ó>Ñ>Ð>r-   Únonce_countrx   c                 ó   — t        |«      j                  «       }||z  }|t        j                  «       j                  «       z  }|t	        j
                  d«      z  }t        j                  |«      j                  «       d d j                  «       S )Né   é   )	rN   r   ÚtimeÚctimeÚosÚurandomÚhashlibÚsha1r�   )r   r¥   rx   Úss       r   r˜   zDigestAuth._get_client_nonce1  sp   € Ü�Ó×#Ñ#Ó%ˆØ	ˆU‰
ˆØ	ŒT�Z‰Z‹\× Ñ Ó"Ñ"ˆØ	ŒR�Z‰Z˜‹]Ñˆä�|‰|˜A‹×(Ñ(Ó*¨3¨BÐ/×6Ñ6Ó8Ð8r-   Úheader_fieldsc                 ó¾   — d}d}d}d}t        |j                  «       «      D ]8  \  }\  }}|dkD  r|dz  }||vr|n|}	||	j                  |t        |«      «      z  }Œ: |S )N)ry   r{   r“   z{}="{}"z{}={}Ú r   z, )Ú	enumerateÚitemsÚformatr   )
r   r°   ÚNON_QUOTED_FIELDSÚQUOTED_TEMPLATEÚNON_QUOTED_TEMPLATEÚheader_valueÚir†   rˆ   Útemplates
             r   r›   zDigestAuth._get_header_value9  sŒ   € Ø6ÐØ#ˆØ%ÐàˆÜ!*¨=×+>Ñ+>Ó+@Ó!Aò 	BÑˆA‰~��uØ�1ŠuØ Ñ$�ð Ð 1Ñ1ñ  à(ð ð
 ˜HŸO™O¨E´6¸%³=ÓAÑA‰Lð	Bð Ðr-   r{   c                 ó†   — |€y t        j                  d|«      }d|v ry|dgk(  rt        d«      ‚d|›d�}t        ||¬«      ‚)Ns   , ?r’   s   auth-intz.Digest auth-int support is not yet implementedzUnexpected qop value "z" in digest authri   )Úrer~   ÚNotImplementedErrorr   )r   r{   r   ÚqopsrŠ   s        r   rš   zDigestAuth._resolve_qopK  sX   € ð ˆ;ØÜ�x‰x˜ Ó$ˆØ�d‰?Øà�K�=Ò Ü%Ð&VÓWÐWà*¨3¨'Ð1AÐBˆÜ˜G¨WÔ5Ð5r-   )r&   r'   r(   r­   Úmd5r®   Úsha256Úsha512rb   r*   ÚDictrN   r7   rO   Ú__annotations__rM   r5   r   r+   r	   r   rn   r=   Úintr˜   r›   r]   rš   r   r-   r   r_   r_   °   sv  … à�{‰{Ø—K‘KØ�|‰|Ø—L‘LØ—>‘>ØŸ™Ø—>‘>ØŸ™ñ	XÐ §¡¨S°&·/±/À5À'È7ÐBRÑ2SÐ-SÑ!Tó 	ðØŸ™ S¨% ZÑ0ðØ<B¿L¹LÈÈeÈÑ<Tðà	óð ð ¨V×-=Ñ-=¸gÀxÐQUÐ>UÑ-Vó ð>CØðCØ*2ðCØADðCà	óCð>-?Øð-?Ø+Að-?à	ó-?ð^9¨Sð 9¸ð 9À5ó 9ð¨v¯{©{¸3À¸:Ñ/Fð È3ó ð$6Ø—?‘? 5Ñ)ð6Ø4;ð6à	�‰˜Ñ	ô6r-   r_   c                   ót   — e Zd ZU eed<   eed<   eed<   ej                  e   ed<   ej                  e   ed<   y)rr   rw   rx   ry   rz   r{   N)r&   r'   r(   rO   rÄ   rN   r*   r]   r   r-   r   rr   rr   [  s/   … ØƒLØƒLØƒNØ�O‰O˜EÑ"Ó"Ø	�‰˜Ñ	Ôr-   rr   )r­   r«   r½   r©   r*   Úbase64r   Úurllib.requestr   Ú_exceptionsr   Ú_modelsr   r   r	   Ú_utilsr
   r   r   ÚTYPE_CHECKINGr   r   r/   r9   rQ   r_   Ú
NamedTuplerr   r   r-   r   ú<module>rÎ      sˆ   ðÛ Û 	Û 	Û Û Ý Ý *å &ß /Ñ /ß -Ñ -à	×ÒÝ÷Xñ Xôv
"�4ô 
"ô �ô  ô. �ô  ô@h6�ô h6ôV ˜6×,Ñ,õ  r-   