+
     hs.  c                  sT   ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
 ^RIHt ^RIHtHtHt ^RIHtHtHt ]P*                  '       d   ^ RIHt . ROt ! R R	4      t ! R R]4      t ! R R
]4      t ! R R]4      t ! R R]4      t ! R R]P:                  4      tR# )    )annotationsN)	b64encode)parse_http_list)ProtocolError)CookiesRequestResponse)to_bytesto_strunquote)_HashAuth	BasicAuth
DigestAuth	NetRCAuthc                  sF    ] tR t^tRtRtRtR R ltR R ltR R lt	R	t
R
# )r   a  
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.
Fc                    V ^8  d   QhRRRR/#    requestr   returnz)typing.Generator[Request, Response, None] format   "0/usr/lib/python3.14/site-packages/httpx/_auth.py__annotate__Auth.__annotate__&   s       -V     c              #  s   "   Vx  R# 5i)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.
Nr   selfr      &&r   	auth_flowZAuth.auth_flow&   s     , s   	c               r   r   r   r   r   r   r   r   >   s      	2r   c              #  s   "   V P                   '       d   VP                  4        V P                  V4      p\        V4      p Vx pV P                  '       d   VP                  4         VP                  V4      pK;    \         d     R# i ; i5i)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_bodyZreadr    nextrequires_response_bodysendStopIterationr   r   Zflowresponse   &&  r   sync_auth_flowZAuth.sync_auth_flow>   sv      %%%LLN~~g&t*$}H***))H-  s0   ABB)A< :B<BB
BBc               r   )r   r   r   r   z(typing.AsyncGenerator[Request, Response]r   r   r   r   r   r   W   s      	1r   c               sJ  "   V P                   '       d   VP                  4       G Rj  xL
  V P                  V4      p\        V4      p V5x pV P                  '       d   VP                  4       G Rj  xL
   VP                  V4      pKD   Ld L  \         d     R# i ; i5i)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!   Zareadr    r"   r#   r$   r%   r&   r(   r   async_auth_flowZAuth.async_auth_flowW   s      %%%--/!!~~g&t*$}H***nn&&&))H- " ' ! sK   &B#B7B#!B#4B5B#:B B#B#B B#B  B#r   N)__name__
__module____qualname____firstlineno____doc__r!   r#   r    r)   r*   __static_attributes__r   r   r   r   r      s)    
 ""02 r   c                  s2    ] tR t^qtRtR R ltR R ltRtR# )FunctionAuthz
Allows the 'auth' argument to be passed as a simple callable function,
that takes the request, and returns a new, modified request.
c               r   )r   funcz#typing.Callable[[Request], Request]r   Noner   r   r   r   r   FunctionAuth.__annotate__w   s      @ T r   c                	s    Wn         R # NZ_func)r   r2   r   r   __init__ZFunctionAuth.__init__w   s    
r   c               r   r   r   r   r   r   r   r4   z   s     " " "-V "r   c              #  	s4   "   V P                  V4      x  R # 5ir5   r6   r   r   r   r    ZFunctionAuth.auth_flowz   s     jj!!s   r6   N)r+   r,   r-   r.   r/   r7   r    r0   r   r   r   r1   r1   q   s    
" "r   r1   c                  s>    ] tR t^~tRtR R ltR R ltR R ltRtR	# )
r   zm
Allows the 'auth' argument to be passed as a (username, password) pair,
and uses HTTP Basic authentication.
c               $    V ^8  d   QhRRRRRR/# r   usernamestr | bytespasswordr   r3   r   r   r   r   r   BasicAuth.__annotate__   s&     H H H H Hr   c                	s2    V P                  W4      V n        R # r5   )_build_auth_header_auth_headerr   r:   r<      &&&r   r7   ZBasicAuth.__init__   s     33HGr   c               r   r   r   r   r   r   r   r=      s       -V r   c              #  	sH   "   V P                   VP                  R &   Vx  R# 5i)AuthorizationN)r?   headersr   r   r   r    ZBasicAuth.auth_flow   s     +/+<+<(s    "c               r8   r   r:   r;   r<   r   strr   r   r   r   r   r=      "        ;  +  RU  r   c                	    R P                  \        V4      \        V4      34      p\        V4      P                  4       pRV 2#    :zBasic joinr   r   Zdecoder   r:   r<   ZuserpassZtoken   &&&  r   r>   ZBasicAuth._build_auth_header   ?    99hx0(82DEF(#**,wr   )r?   N	r+   r,   r-   r.   r/   r7   r    r>   r0   r   r   r   r   r   ~   s    
H   r   c                  sB    ] tR t^tRtR
R R lltR R ltR R ltR	tR# )r   zL
Use a 'netrc' file to lookup basic auth credentials based on the url host.
Nc               r   )r   filez
str | Noner   r3   r   r   r   r   r   NetRCAuth.__annotate__   s     - -Z -4 -r   c                	s:    ^ RI pVP                  V4      V n        R# )r    N)netrc_netrc_info)r   rP   rR      && r   r7   ZNetRCAuth.__init__   s     	 ;;t,r   c               r   r   r   r   r   r   r   rQ      s     
 
 
-V 
r   c              #  	s  "   V P                   P                  VP                  P                  4      pVe   V^,          '       g   Vx  R # V P	                  V^ ,          V^,          R7      VP
                  R&   Vx  R # 5i)N)r:   r<   rB   )rS   ZauthenticatorsurlZhostr>   rC   )r   r   Z	auth_inforT   r   r    ZNetRCAuth.auth_flow   sm     $$33GKK4D4DE	IaLLM 04/F/F"1	! 0G 0GOOO, Ms   AA?:A?c               r8   rD   r   r   r   r   r   rQ      rF   r   c                	rG   rH   rJ   rL   rM   r   r>   ZNetRCAuth._build_auth_header   rN   r   )rS   r5   rO   r   r   r   r   r      s    -
   r   c                  s:   ] tR t^t$ R]P
                  R]P
                  R]P                  R]P                  R]P                  R]P                  R]P                  R]P                  /t	R	]
R
&   R R ltR R ltR R ltR R ltR R ltR R ltR R ltRtR# )r   MD5zMD5-SESSZSHAzSHA-SESSzSHA-256zSHA-256-SESSzSHA-512zSHA-512-SESSz*dict[str, typing.Callable[[bytes], _Hash]]_ALGORITHM_TO_HASH_FUNCTIONc               r8   r9   r   r   r   r   r   DigestAuth.__annotate__   s!         r   c                	sb    \        V4      V n        \        V4      V n        R V n        ^V n        R # r5   )r   	_username	_password_last_challenge_nonce_countr@   rA   r   r7   ZDigestAuth.__init__   s*    !(+!(+<@r   c               r   r   r   r   r   r   r   rX      s       -V r   c              #  	sj  "   V P                   '       d)   V P                  WP                   4      VP                  R &   Vx pVP                  R8w  g   RVP                  9  d   R# VP                  P	                  R4       F*  pVP                  4       P                  R4      '       g   K*   M	  R# V P                  WV4      V n         ^V n        V P                  WP                   4      VP                  R &   VP                  '       d&   \        VP                  4      P                  VR7       Vx  R# 5i)rB   i  zwww-authenticateNzdigest r   )r[   r>   rC   Zstatus_codeZget_listlowerZ
startswith_parse_challenger\   Zcookiesr   Zset_cookie_header)r   r   r'   auth_headerr(   r   r    ZDigestAuth.auth_flow   s
    /3/F/F--0GOOO, !=3&*<HDTDT*T #++445GHK  "--i88 I #44WT+/+B+B)),
( H$$%777Hs   B#D3*B	D3c               s(    V ^8  d   QhRRRRRRRR/# )	r   r   r   r'   r   r`   rE   r   _DigestAuthChallenger   r   r   r   r   rX      s2     C CC*2CADC	Cr   c                sB   VP                  R4      w  rEpVP                  4       R8X  g   Q h/ p\        V4       F2  pVP                  4       P	                  R^4      w  r\        V
4      Wy&   K4  	   VR,          P                  4       pVR,          P                  4       pVP                  RR4      pRV9   d   VR,          P                  4       MR	pR
V9   d   VR
,          P                  4       MR	p\        WWVR7      #   \         d   pRp\        TTR7      ThR	p?ii ; i)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"`
Z digestZ=realmnonce	algorithmrV   opaqueNqop)rc   rd   re   rf   rg   z(Malformed Digest WWW-Authenticate headerr]   )Z	partitionr^   r   Zstripsplitr
   encodeZgetra   ZKeyErrorr   )r   r   r'   r`   ZschemeZ_ZfieldsZheader_dictfieldZkeyvaluerc   rd   re   rf   rg   Zexcmessages   &&&&              r   r_   ZDigestAuth._parse_challenge   s    (11#66 ||~)))&($V,E,,S!4JC&u~K -	C(//1E(//1E#U;I7?;7N[*113TXF16+1E+e$++-4C'IRU   	C@G9sB	Cs   0BC> >D	DDc               s$    V ^8  d   QhRRRRRR/# )r   r   r   	challengera   r   rE   r   r   r   r   r   rX      s$     .? .?.?+?.?	.?r   c                	s  a V P                   VP                  P                  4       ,          oR  V3R llpRP                  V P                  VP
                  V P                  34      pVP                  P                  pRP                  VP                  P                  4       V34      pV! V4      pRV P                  ,          pV P                  V P                  VP                  4      p	V ;P                  ^,          un        V! V4      p
VP                  P                  4       P                  R4      '       d$   V! RP                  WP                  V	34      4      p
V P!                  VP"                  VR7      pVf   WP                  V.pMWP                  WW.pRV P                  RVP
                  RVP                  R	VR
V! RP                  V4      4      RVP                  P                  4       /pVP$                  '       d   VP$                  VR&   V'       d   RVR&   WR&   WR&   RV P'                  V4      ,           # )c               s     V ^8  d   QhRRRR/# )r   databytesr   r   r   r   r   r   Z3DigestAuth._build_auth_header.<locals>.__annotate__  s     	8 	8 	85 	8r   c                sL   < S! V 4      P                  4       P                  4       # r5   )	hexdigestri   )rn   	hash_funcs   &r   rb   Z-DigestAuth._build_auth_header.<locals>.digest  s    T?,,.5577r   rI   s   %08xz-sessr]   r:   rc   rd   Zurir'   re   rf      authrg   nccnoncezDigest )rW   re   ZupperrK   rY   rc   rZ   rU   Zraw_pathZmethodri   r\   _get_client_noncerd   r^   Zendswith_resolve_qoprg   rf   _get_header_value)r   r   rm   rb   ZA1ZpathZA2ZHA2Znc_valuert   ZHA1rg   Zdigest_dataZformat_argsrq   s   &&&           @r   r>   ZDigestAuth._build_auth_header   s    44Y5H5H5N5N5PQ		8 	8 YY	HI{{##YY--/67RjT...''(9(99??KQRj$$&//88C&#ABCC	w?;5K 3LK Y__Y__4tyy56,,335
 $-$4$4K!!(K ($*!411+>>>r   c               s$    V ^8  d   QhRRRRRR/# )r   nonce_countZintrd   ro   r   r   r   r   r   r   rX   /  s!     9 9S 9 95 9r   c                	sD   \        V4      P                  4       pW2,          pV\        P                  ! 4       P                  4       ,          pV\        P
                  ! ^4      ,          p\        P                  ! V4      P                  4       R,          P                  4       # )i   :Ni   N)	rE   ri   timeZctimeosZurandomhashlibsha1rp   )r   rx   rd   Zss   &&& r   ru   ZDigestAuth._get_client_nonce/  sl    ##%	
	TZZ\  ""	RZZ]||A((*3/6688r   c               r   )r   header_fieldszdict[str, bytes]r   rE   r   r   r   r   r   rX   7  s      /? C r   c                	s    RpRpRpRp\        VP                  4       4       FC  w  pw  rxV^ 8  d
   VR,          pWr9  d   TMTp	WYP                  V\        V4      4      ,          pKE  	  V# )re   z{}="{}"z{}={}Z z, )re   rg   rs   )Z	enumerateZitemsr   r	   )
r   r}   ZNON_QUOTED_FIELDSZQUOTED_TEMPLATEZNON_QUOTED_TEMPLATEZheader_valueZirj   rk   Ztemplates
   &&        r   rw   ZDigestAuth._get_header_value7  s    6#%!*=+>+>+@!AA~1u$ 1  ( 
 OOE6%=AAL "B r   c               s$    V ^8  d   QhRRRRRR/# )r   rg   bytes | Noner   r   r   r   r   r   r   r   rX   I  s!     6 6 6w 6< 6r   c                	s    Vf   R # \         P                  ! RV4      pRV9   d   R# VR.8X  d   \        R4      hRV: R2p\        WBR7      h)Ns   , ?rr   s   auth-intz.Digest auth-int support is not yet implementedzUnexpected qop value "z" in digest authr]   )rerh   ZNotImplementedErrorr   )r   rg   r   Zqopsrl   rM   r   rv   ZDigestAuth._resolve_qopI  sT    ;xx$d?K= %&VWW*3'1ABG55r   )r[   r\   rZ   rY   N)r+   r,   r-   r.   r{   Zmd5r|   Zsha256Zsha512rW   __annotations__r7   r    r_   r>   ru   rw   rv   r0   r   r   r   r   r      s    w{{GKKw||GLL7>>7>>	O!K 	>C>.?`9$6 6r   c                  sJ    ] tR tRt$ R]R&   R]R&   R]R&   R]R&   R]R	&   R
tR# )ra   iW  ro   rc   rd   rE   re   r~   rf   rg   r   N)r+   r,   r-   r.   r   r0   r   r   r   ra   ra   W  s    LLN	r   ra   )r   r   r   r   )Z
__future__r   r{   rz   r   ry   ZtypingZbase64r   Zurllib.requestr   Z_exceptionsr   Z_modelsr   r   r   Z_utilsr   r	   r
   ZTYPE_CHECKINGr   Z__all__r   r1   r   r   r   Z
NamedTuplera   r   r   r   <module>r      s    "  	 	    * & / / - -	 ;X Xv
"4 
"   &   <e6 e6P6,, r   