ó
    °"³j|  ã                  ó  • % S SK Jr  S SKrS SKrS SKJrJr  S SKJr  S SK	r	SSK
Jr  SSKJr  S/r\R                  " \5      rS	\S
'   \R&                  " 5       r\" 5       rS\S'   SS jrSS jrSS jr " S S\	R4                  5      rg)é    )ÚannotationsN)Ú	GeneratorÚAsyncGenerator)Úoverrideé   )Ú
TokenCache)ÚOAUTH_API_BETA_HEADERÚAccessTokenAuthzlogging.LoggerÚlogzset[str]Ú_warn_once_seenc                óÄ   • [            U [        ;   a
   SSS5        g[        R                  U 5        SSS5        [        R                  " U/UQ76   g! , (       d  f       N&= f)z6Emit a log warning at most once per `key` per process.N)Ú_warn_once_lockr   Úaddr   Úwarning)ÚkeyÚmessageÚargss      Ú\/home/mande/repo/quber/.venv/lib/python3.13/site-packages/anthropic/lib/credentials/_auth.pyÚ
_warn_oncer      sG   € æ	Ø”/Ó!Ø÷ 
ˆô 	×Ñ˜CÔ ÷ 
ô ‡K‚K�Ð˜$Ô÷	 
�ús   ‡AœAÁ
Ac                ó$   • [        SU  3SU 5        g)aI  Warn that an explicit `api_key=` / `auth_token=` argument shadows
an explicit `credentials=` provider passed to the same constructor or
`copy()` call. The static credential wins at the request-header level
(`AccessTokenAuth.sync_auth_flow` short-circuits on the pre-set header),
which silently disables the credentials provider.
zexplicit-shadow:z“`%s=` was passed alongside `credentials=`; the static credential takes precedence and the credentials provider is silently disabled. Pass only one.N©r   )Úparams    r   Ú(warn_explicit_static_shadows_credentialsr      s    € ô Ø
˜5˜'Ð"ð	ð 	õó    c                ó&   • [        SU  3SU U 5        g)a‡  Warn that an `ANTHROPIC_API_KEY` / `ANTHROPIC_AUTH_TOKEN` from the
environment is shadowing the SDK's profile / federation auto-discovery.

Per the credential-precedence spec, a static-credential env var silently
disables the auto-discovered federation and profile paths. Surface a
one-shot warning so migrating users can see why their `ANTHROPIC_PROFILE`
or WIF env vars are being ignored.
zenv-shadow:z‚%s is set and takes precedence over the SDK's profile / federation auto-discovery; unset %s to use the auto-discovered credential.Nr   )Úenv_vars    r   Ú&warn_env_static_shadows_auto_discoveryr   .   s"   € ô Ø
�g�YÐð	JàØõr   c                  ól   • \ rS rSrSrSrSS jr\SS j5       rSS jr	\
SS j5       r\
SS j5       rS	rg
)r
   é@   uI  Adapts a `TokenCache` to httpx's `httpx2.Auth` protocol.

Used by `anthropic.Anthropic.custom_auth` to inject `Authorization: Bearer`
plus the OAuth beta header on every request, with proactive refresh handled by
`TokenCache`.

Static credentials shadow federation: if the outgoing request already carries
an `X-Api-Key` or `Authorization` header (set by the client's api_key /
auth_token path), this auth flow is a no-op. That matches the Go SDK's
`authMiddleware` and the documented precedence in the WIF user guide â€”
a static `ANTHROPIC_API_KEY` shadows any credentials provider.
Fc                ó   • Xl         g ©N©Ú_token_cache)ÚselfÚtoken_caches     r   Ú__init__ÚAccessTokenAuth.__init__P   s   € Ø'Õr   c                óŽ   • [        U R                  R                  S5      =(       d    U R                  R                  S5      5      $ )Nz	X-Api-KeyÚAuthorization)ÚboolÚheadersÚget)Úrequests    r   Ú_has_static_credentialÚ&AccessTokenAuth._has_static_credentialS   s0   € ä�G—O‘O×'Ñ'¨Ó4×\¸¿¹×8KÑ8KÈOÓ8\Ó]Ð]r   c                óp  • SU 3UR                   S'   UR                   R                  SS5      nUR                  S5       Vs/ s H)  oDR                  5       (       d  M  UR                  5       PM+     nn[        U;  a4  UR                  [        5        SR                  U5      UR                   S'   g g s  snf )NzBearer r)   zanthropic-betaÚ Ú,)r+   r,   ÚsplitÚstripr	   ÚappendÚjoin)r$   r-   ÚtokenÚexisting_betaÚflagÚexisting_flagss         r   Ú_applyÚAccessTokenAuth._applyW   sš   € Ø-4°U°GÐ+<ˆ�‰˜Ñ(ØŸ™×+Ñ+Ð,<¸bÓAˆð 4A×3FÑ3FÀsÔ3KÓ\Ò3K¨4ÏzÉzÏ|›,˜$Ÿ*™*ž,Ñ3KˆÐ\Ü ¨Ó6Ø×!Ñ!Ô"7Ô8Ø03·±¸Ó0HˆG�O‰OÐ,Ò-ð 7ùò ]s   ÁB3ÁB3c              #  ó    #   • U R                  U5      (       a  Uv •  g U R                  R                  5       nU R                  X5        Uv •  g 7fr!   )r.   r#   Ú	get_tokenr;   ©r$   r-   r7   s      r   Úsync_auth_flowÚAccessTokenAuth.sync_auth_flowg   sC   é € à×&Ñ& w×/Ñ/ØŠMØØ×!Ñ!×+Ñ+Ó-ˆØ�‰�GÔ#Ø‹ùs   ‚AAc               ó¸   #   • U R                  U5      (       a  U7v •  g U R                  R                  5       I S h  v•N nU R                  X5        U7v •  g  N7fr!   )r.   r#   Úasync_get_tokenr;   r?   s      r   Úasync_auth_flowÚAccessTokenAuth.async_auth_flowp   sK   é € à×&Ñ& w×/Ñ/Ø‹MØØ×'Ñ'×7Ñ7Ó9×9ˆØ�‰�GÔ#ØŒñ :ùs   ‚:A¼A½Ar"   N)r%   r   ÚreturnÚNone)r-   úhttpx2.RequestrF   r*   )r-   rH   r7   ÚstrrF   rG   )r-   rH   rF   z0Generator[httpx2.Request, httpx2.Response, None])r-   rH   rF   z/AsyncGenerator[httpx2.Request, httpx2.Response])Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úrequires_response_bodyr&   Ústaticmethodr.   r;   r   r@   rD   Ú__static_attributes__© r   r   r
   r
   @   sX   † ñð #Ðô(ð ó^ó ð^ôIð  óó ðð óó ór   )r   rI   r   rI   r   ÚobjectrF   rG   )r   rI   rF   rG   )r   rI   rF   rG   )Ú
__future__r   ÚloggingÚ	threadingÚtypingr   r   Útyping_extensionsr   Úhttpx2Ú_cacher   Ú
_constantsr	   Ú__all__Ú	getLoggerrJ   r   Ú__annotations__ÚLockr   Úsetr   r   r   r   ÚAuthr
   rR   r   r   Ú<module>rb      sq   ðÞ "ã Û ß ,Ý &ã å Ý -àÐ
€à×'Ò'¨Ó1€€^Ó 1à—.’.Ó"€Ù›E€�Ó !ô ôô ô$7�f—k‘kõ 7r   