§
    ÜŽ’jM¥  ã                  ó  — U d dl mZ d dlZd dlZd dlZ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mZmZmZmZmZ d dlmZ d dlZddlmZmZ ddlmZmZmZmZmZmZ ddlmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4 d	d
l5m6Z6  ej7        e8¦  «        Z9de:d<   erddl;m<Z< g d¢Z=d)d„Z>dZ?dZ@dZAdZBdZCd*d„ZD G d„ d ¦  «        ZE G d!„ d"¦  «        ZF G d#„ d$¦  «        ZG G d%„ d&¦  «        ZH G d'„ d(eG¦  «        ZIdS )+é    )ÚannotationsN)ÚTYPE_CHECKINGÚAnyÚDictÚUnionÚOptionalÚcast)Úoverrideé   )ÚAccessTokenÚIdentityTokenProvider)Ú	SecretStrÚ_unwrap_secretÚ_strip_tracebackÚ_json_dumps_secretsÚ_wrap_secret_fieldsÚ_NonObjectPayloadError)Ú	ENV_SCOPEÚENV_PROFILEÚENV_BASE_URLÚENV_AUTH_TOKENÚENV_CONFIG_DIRÚTOKEN_ENDPOINTÚDEFAULT_BASE_URLÚENV_WORKSPACE_IDÚENV_ORGANIZATION_IDÚOAUTH_API_BETA_HEADERÚENV_FEDERATION_RULE_IDÚENV_SERVICE_ACCOUNT_IDÚTOKEN_EXCHANGE_TIMEOUTÚENV_IDENTITY_TOKEN_FILEÚGRANT_TYPE_REFRESH_TOKENÚMANDATORY_REFRESH_SECONDSÚ_user_agentÚ_require_httpsÚ_active_profileÚ_config_file_pathÚ_credentials_file_pathÚresolve_identity_token_pathé   )ÚAnthropicErrorzlogging.LoggerÚlog)ÚWorkloadIdentityCredentials)ÚStaticTokenÚEnvTokenÚCredentialsFileÚInMemoryConfigÚIdentityTokenFileÚvaluer   ÚsourceúOptional[pathlib.Path]ÚreturnúOptional[int]c                óš   — | €dS 	 t          | ¦  «        S # t          t          f$ r$}|�d|› �nd}t          |› d| ›d�¦  «        |‚d}~ww xY w)z@Parse a credentials-file ``expires_at`` field into Unix seconds.Nzcredentials file at Úcredentialsz has invalid 'expires_at' u“   ; expected an integer Unix timestamp in seconds. The SDK does not parse ISO8601 â€” convert with int(datetime.timestamp()) before writing the file.)ÚintÚ	TypeErrorÚ
ValueErrorr+   )r3   r4   ÚerrÚwheres       úRC:\Projects\DSCons\.venv\Lib\site-packages\anthropic\lib\credentials\_providers.pyÚ_coerce_expires_atr@   ;   s“   € à€}ØˆtðÝ�5‰zŒzÐøÝ•zÐ"ð ð ð Ø39Ð3EÐ/ vÐ/Ð/Ð/È=ˆÝØð Gð G°ð Gð Gð Gñ
ô 
ð ð		øøøøðøøøs   † •A
¦AÁA
Úoauth_tokenz1.0Úoidc_federationÚ
user_oauthÚconfigúDict[str, Any]ÚauthÚNonec                óö  — dd„} || d	t           ¦  «          || d
t          ¦  «          || dt          ¦  «         |                     d¦  «        }|t          k    r ||dt
          ¦  «          ||dt          ¦  «          ||dt          ¦  «         |                     d¦  «        s0t          j	                             t          ¦  «        }|rd|dœ|d<   dS dS dS |t          k    r ||dt          ¦  «         dS dS )uÐ   Fill empty profile fields from corresponding ANTHROPIC_* env vars.

    The profile file is authoritative â€” this only fills fields the file left
    unset. Empty-string env values are treated as unset.
    ÚtargetrE   ÚkeyÚstrÚenv_varr6   rG   c                ó„   — |                       |¦  «        s(t          j                              |¦  «        }|r	|| |<   d S d S d S ©N)ÚgetÚosÚenviron)rI   rJ   rL   Úvs       r?   Úfillz$_fill_missing_from_env.<locals>.fill^   sP   € à�zŠz˜#‰Œð 	 Ý”
—’˜wÑ'Ô'ˆAØð  Ø��s‘��ð	 ð 	 ð ð  ó    Úbase_urlÚorganization_idÚworkspace_idÚtypeÚfederation_rule_idÚservice_account_idÚscopeÚidentity_tokenÚfile)r4   ÚpathN)rI   rE   rJ   rK   rL   rK   r6   rG   )r   r   r   rO   ÚAUTH_TYPE_OIDC_FEDERATIONr   r   r   rP   rQ   r!   ÚAUTH_TYPE_USER_OAUTH)rD   rF   rS   Ú	auth_typerR   s        r?   Ú_fill_missing_from_envrb   W   sF  € ð ð  ð  ð  ð 	€Dˆ��\Ñ*Ô*Ð*Ø€DˆÐ"Õ$7Ñ8Ô8Ð8Ø€Dˆ�Õ!1Ñ2Ô2Ð2à—’˜Ñ Ô €IØÕ-Ò-Ð-ØˆˆTÐ'Õ)?Ñ@Ô@Ð@ØˆˆTÐ'Õ)?Ñ@Ô@Ð@ØˆˆT�7�IÑ&Ô&Ð&Ø�xŠxÐ(Ñ)Ô)ð 	GÝ”
—’Õ6Ñ7Ô7ˆAØð GØ4:ÀAÐ)FÐ)F�Ð%Ñ&Ð&Ð&ð	Gð 	GðGð Gà	Õ*Ò	*Ð	*ØˆˆT�7�IÑ&Ô&Ð&Ð&Ð&ð 
+Ð	*rT   c                  ó(   — e Zd ZdZdd„Zddœdd„ZdS )r.   zQAn :class:`AccessTokenProvider` that always returns a fixed token with no expiry.ÚtokenrK   r6   rG   c                ó   — || _         d S rN   )Ú_token)Úselfrd   s     r?   Ú__init__zStaticToken.__init__y   s   € ØˆŒˆˆrT   F©Úforce_refreshrj   Úboolr   c               ó0   — ~t          | j        d ¬¦  «        S )N©rd   Ú
expires_at)r   rf   )rg   rj   s     r?   Ú__call__zStaticToken.__call__|   s   € ØÝ ¤¸Ð>Ñ>Ô>Ð>rT   N)rd   rK   r6   rG   ©rj   rk   r6   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rh   ro   © rT   r?   r.   r.   v   sQ   € € € € € Ø[Ð[ðð ð ð ð 16ð ?ð ?ð ?ð ?ð ?ð ?ð ?ð ?rT   r.   c                  ó,   — e Zd ZdZefdd„Zddœdd„ZdS )r/   zQAn :class:`AccessTokenProvider` that reads ``ANTHROPIC_AUTH_TOKEN`` at call time.rL   rK   r6   rG   c                ó   — || _         d S rN   )Ú_env_var)rg   rL   s     r?   rh   zEnvToken.__init__„   s   € ØˆŒˆˆrT   Fri   rj   rk   r   c               ó¢   — ~t           j                             | j        ¦  «        }|€t	          d| j        › d�¦  «        ‚t          |d ¬¦  «        S )NzEnvironment variable zN is not set. Set it or pass an explicit `credentials=` provider to the client.rm   )rP   rQ   rO   rx   r+   r   )rg   rj   r3   s      r?   ro   zEnvToken.__call__‡   sb   € ØÝ”
—’˜tœ}Ñ-Ô-ˆØˆ=Ý ðU¨¬ð Uð Uð Uñô ð õ  °4Ð8Ñ8Ô8Ð8rT   N)rL   rK   r6   rG   rp   )rq   rr   rs   rt   r   rh   ro   ru   rT   r?   r/   r/   �   sY   € € € € € Ø[Ð[à&4ð  ð  ð  ð  ð  ð 16ð 9ð 9ð 9ð 9ð 9ð 9ð 9ð 9rT   r/   c                  óþ   — e Zd ZdZ	 d/ddœd0d
„Zed1d„¦   «         Zed2d„¦   «         Zed3d„¦   «         Zd4d„Z	d5d„Z
d6d„Zd7d„Zd8d„Zd8d„Zd9d„Zd:d„Zd:d„Zd;d „Zd8d!„Zd"d#œd<d'„Zd"d#œd=d)„Zd>d+„Zd"d#œd=d,„Zd?d.„ZdS )@r0   uí  An :class:`AccessTokenProvider` backed by a named profile.

    A profile is a pair of files under the config directory
    (``~/.config/anthropic/`` by default; override with ``ANTHROPIC_CONFIG_DIR``):

    * ``configs/<profile>.json`` â€” non-secret. Holds the nested
      ``"authentication"`` object (discriminated by its ``"type"`` field), plus
      top-level ``organization_id``, ``workspace_id``, and ``base_url``.
      The ``authentication`` object may contain a ``credentials_path`` field
      overriding the credentials file location.
    * ``credentials/<profile>.json`` â€” secret (0600). Holds ``access_token``,
      ``expires_at``, and (for ``user_oauth`` with a ``client_id``)
      ``refresh_token``.

    The split keeps secret material out of files that may need to be readable
    by config-only consumers, and lets the SDK enforce 0600 on the credentials
    file without locking out config readers.

    Dispatches on the ``authentication.type`` discriminator:

    ``"oidc_federation"``
        OIDC workload identity federation. Lazily constructs a
        :class:`WorkloadIdentityCredentials` delegate from the nested auth
        fields plus the top-level ``organization_id`` and calls it to perform
        the jwt-bearer exchange.

    ``"user_oauth"``
        Output of an interactive PKCE login. If the auth block has a
        ``client_id``, performs ``refresh_token`` grants on expiry and
        writes the new tokens back to the credentials file (atomic replace,
        refresh-token rotation supported). Without a ``client_id``, the
        credentials file is treated as externally rotated â€” the SDK re-reads
        it on every invocation and returns whatever ``access_token`` is
        there, no refresh grant attempted. This is the pattern for a
        sidecar/daemon that mints the access token out-of-band.

    Args:
        profile: Profile name. ``None`` resolves via ``ANTHROPIC_PROFILE`` env
            â†’ ``<config_dir>/active_config`` pointer file â†’ ``"default"``.
    N)Úhttp_clientÚprofileúOptional[str]r{   úOptional[httpx.Client]r6   rG   c               óÒ   — |�|nt          ¦   «         | _        t          | j        ¦  «        | _        d | _        || _        d | _        d | _        d | _        t          | _
        d | _        d S rN   )r&   Ú_profiler'   Ú_config_pathÚ_bound_base_urlÚ_http_clientÚ_owned_http_clientÚ_configÚ_credentials_pathr   Ú	_base_urlÚ_workload_delegate)rg   r|   r{   s      r?   rh   zCredentialsFile.__init__¼   sj   € ð $+Ð#6˜˜½OÑ<MÔ<MˆŒÝ-¨d¬mÑ<Ô<ˆÔØ.2ˆÔØ'ˆÔØ:>ˆÔð 26ˆŒØ9=ˆÔÝ.ˆŒØIMˆÔÐÐrT   rK   c                ó   — | j         S rN   )r€   ©rg   s    r?   r|   zCredentialsFile.profileÏ   s
   € àŒ}ÐrT   úpathlib.Pathc                ó   — | j         S rN   )r�   rŠ   s    r?   Úconfig_pathzCredentialsFile.config_pathÓ   s   € àÔ Ð rT   c                ó    — |                       ¦   «         }|                     d¦  «        }|r"t          |¦  «                             d¦  «        ndS )u‰  The ``base_url`` declared in the profile config file, if any.

        Returns ``None`` when the config has no top-level ``base_url`` key â€”
        callers should fall back to their own default rather than the
        provider's bound/default value, so a profile that *doesn't* pin a
        host never overrides an explicit client setting. Loads the config
        on first access.
        rU   ú/N)Ú_load_configrO   rK   Úrstrip)rg   rD   Úraws      r?   Úresolved_base_urlz!CredentialsFile.resolved_base_url×   sH   € ð ×"Ò"Ñ$Ô$ˆØ�jŠj˜Ñ$Ô$ˆØ'*Ð4�s�3‰xŒx�Š˜sÑ#Ô#Ð#°Ð4rT   rU   c                óü   — |                      d¦  «        }t          || j        › d�¬¦  «         || _        | j        �?|                      | j        ¦  «        | _        t          | j        | j        › d�¬¦  «         dS dS )a`  Adopt the owning client's ``base_url`` as a fallback for the token
        exchange. Slots between the config file's own ``base_url`` field and
        the hard-coded default; a ``base_url`` in the config file still wins.

        Rebinding affects every client holding this instance; clients bind
        through :meth:`for_base_url` instead.
        r�   ú
: base_url©ÚfieldN)r‘   r%   r�   r‚   r…   Ú_resolve_base_urlr‡   )rg   rU   Úbounds      r?   Úbind_base_urlzCredentialsFile.bind_base_urlå   sŒ   € ð —’ Ñ$Ô$ˆõ 	�u tÔ'8Ð$DÐ$DÐ$DÐEÑEÔEÐEØ$ˆÔØŒ<Ð#Ø!×3Ò3°D´LÑAÔAˆDŒNÝ˜4œ>°DÔ4EÐ1QÐ1QÐ1QÐRÑRÔRÐRÐRÐRð $Ð#rT   ú'CredentialsFile'c                óæ  — |                      d¦  «        }| j        �| j        |k    r|                      |¦  «         | S |                      ¦   «         }|                     d¦  «        s0|                      ¦   «                              d¦  «        t          k    r| S t          j        | ¦  «        }|                      ¦   «         |_	        d|_
        d|_        d|_        |                     |¦  «         |S )aî  Return the provider a client with ``base_url`` should exchange through.

        Binds in place, unless another client already bound this instance to a
        different host (e.g. the parent of ``copy(base_url=...)``). That binding
        is left alone, and what happens depends on the profile:

        * pins its own ``base_url``: the bind is irrelevant, return ``self``.
        * ``oidc_federation``: return a copy bound to ``base_url``. It shares the
          identity token and http client, but not the on-disk token cache, whose
          tokens belong to the original deployment.
        * ``user_oauth``: return ``self``. The refresh token is tied to the
          deployment that issued it, so there is nothing per-host to copy.
        r�   NrU   rX   )r‘   r‚   rš   r�   rO   Ú_auth_blockr_   ÚcopyÚ_get_http_clientrƒ   r„   rˆ   r†   )rg   rU   r™   rD   Úproviders        r?   Úfor_base_urlzCredentialsFile.for_base_urlö   så   € ð —’ Ñ$Ô$ˆØÔÐ'¨4Ô+?À5Ò+HÐ+HØ×Ò˜uÑ%Ô%Ð%ØˆKØ×"Ò"Ñ$Ô$ˆØ�:Š:�jÑ!Ô!ð 	 T×%5Ò%5Ñ%7Ô%7×%;Ò%;¸FÑ%CÔ%CÕG`Ò%`Ð%`ØˆKÝ”9˜T‘?”?ˆØ $× 5Ò 5Ñ 7Ô 7ˆÔØ&*ˆÔ#Ø&*ˆÔ#Ø%)ˆÔ"Ø×Ò˜uÑ%Ô%Ð%ØˆrT   rD   rE   c                ó¦   — |                      d¦  «        r(t          |d         ¦  «                             d¦  «        S | j        �| j        S t          S )u+  base_url precedence: top-level config field â†’ bound (the owning
        client's base_url, via :meth:`bind_base_url`) â†’ default. Validated
        against the scheme/TLS rules so a malicious config with
        ``base_url="http://evil/"`` can't exfiltrate the assertion or refresh
        token.rU   r�   )rO   rK   r‘   r‚   r   ©rg   rD   s     r?   r˜   z!CredentialsFile._resolve_base_url  sQ   € ð �:Š:�jÑ!Ô!ð 	7Ý�v˜jÔ)Ñ*Ô*×1Ò1°#Ñ6Ô6Ð6ØÔÐ+ØÔ'Ð'ÝÐrT   úDict[str, str]c                óä   — |                       ¦   «         }i }|                      ¦   «                              d¦  «        t          k    r)|                     d¦  «        }|rt	          |¦  «        |d<   |S )z×Return headers derived from the config file (e.g. ``workspace_id``).

        Eagerly reads the config if not yet loaded. The returned dict is
        suitable for merging into the client's default headers.
        rX   rW   zanthropic-workspace-id)r�   r�   rO   r_   rK   )rg   rD   ÚheadersrW   s       r?   Úextra_headerszCredentialsFile.extra_headers  st   € ð ×"Ò"Ñ$Ô$ˆØ"$ˆð ×ÒÑÔ×!Ò! &Ñ)Ô)Õ-FÒFÐFØ!Ÿ:š: nÑ5Ô5ˆLØð FÝ47¸Ñ4EÔ4E�Ð0Ñ1ØˆrT   c                ó¨  — | j         �| j         S 	 | j                             d¬¦  «        }nr# t          $ r6}t	          d| j        › d| j        ›dt          › dt          › d�	¦  «        |‚d}~wt          t          f$ r }t	          d	| j        › d
|› �¦  «        |‚d}~ww xY w	 t          j        |¦  «        }n2# t          j        $ r }t	          d	| j        › d|› �¦  «        |‚d}~ww xY wt          |t          ¦  «        s-t	          d	| j        › dt          |¦  «        j        › d�¦  «        ‚t#          d|¦  «        }|                     d¦  «        }t          |t          ¦  «        s(t	          d	| j        › dt&          › dt(          › d�¦  «        ‚t#          d|¦  «        }t+          ||¦  «         |                      |¦  «        | _        t1          | j        | j        › d�¬¦  «         |                     d¦  «        }|r9t3          j        t7          |¦  «        ¦  «                             ¦   «         | _        nt=          | j        ¦  «        | _        || _         |S )zPRead and cache the config file, resolving ``base_url`` and ``credentials_path``.Núutf-8©ÚencodingzConfig file not found at ú
 (profile z). Set z' to select a different profile, or set z" to relocate the config directory.zConfig file at ú could not be read: ú is not valid JSON: ú! must contain a JSON object, not ú.rE   ÚauthenticationzV is missing the 'authentication' object. Expected shape: {"authentication": {"type": "ú"|"ú", ...}, ...}r•   r–   Úcredentials_path)r…   r�   Ú	read_textÚFileNotFoundErrorr+   r€   r   r   ÚOSErrorÚUnicodeDecodeErrorÚjsonÚloadsÚJSONDecodeErrorÚ
isinstanceÚdictrX   rq   r	   rO   r_   r`   rb   r˜   r‡   r%   ÚpathlibÚPathrK   Ú
expanduserr†   r(   )rg   r’   r=   Ú
raw_configrD   Úraw_authrF   r
   s           r?   r�   zCredentialsFile._load_config2  sÜ  € àŒ<Ð#Ø”<Ðð		jØÔ#×-Ò-°wÐ-Ñ?Ô?ˆCˆCøÝ ð 	ð 	ð 	Ý ð5¨DÔ,=ð 5ð 5ÈÌð 5ð 5Ý"ð5ð 5ÝKYð5ð 5ð 5ñô ð ð	øøøøõ
 Õ+Ð,ð 	jð 	jð 	jÝ Ð!_°4Ô3DÐ!_Ð!_ÐZ]Ð!_Ð!_Ñ`Ô`ÐfiÐiøøøøð	jøøøð	jÝ"œj¨™oœoˆJˆJøÝÔ#ð 	jð 	jð 	jÝ Ð!_°4Ô3DÐ!_Ð!_ÐZ]Ð!_Ð!_Ñ`Ô`ÐfiÐiøøøøð	jøøøõ ˜*¥dÑ+Ô+ð 	Ý Ør $Ô"3ÐrÐrÕVZÐ[eÑVfÔVfÔVoÐrÐrÐrñô ð õ Ð&¨
Ñ3Ô3ˆà—:’:Ð.Ñ/Ô/ˆÝ˜(¥DÑ)Ô)ð 	Ý ðX $Ô"3ð Xð Xå-ðXð Xå2FðXð Xð Xñô ð õ
 Ð$ hÑ/Ô/ˆõ 	˜v tÑ,Ô,Ð,à×/Ò/°Ñ7Ô7ˆŒÝ�t”~°Ô0AÐ-MÐ-MÐ-MÐNÑNÔNÐNà—8’8Ð.Ñ/Ô/ˆØð 	KÝ%,¤\µ#°h±-´-Ñ%@Ô%@×%KÒ%KÑ%MÔ%MˆDÔ"Ð"å%;¸D¼MÑ%JÔ%JˆDÔ"àˆŒØˆs8   �, ¬
B¶1A'Á'BÁ;BÂBÂB4 Â4C#ÃCÃC#c           	     óÎ  — | j         €J ‚| j         }t          j        dk    rï	 t          j        |d¬¦  «        }nQ# t          $ r!}t          d|› d| j        ›d�¦  «        |‚d}~wt          $ r}t          d|› d	|› �¦  «        |‚d}~ww xY wt          j        |j	        ¦  «        rt          d|› d
�¦  «        ‚t          j
        |j	        ¦  «        }|dz  rt          d|› d|d›d|› d�¦  «        ‚|dz  rt                               d|||¦  «         	 t          t          j        |                     d¬¦  «        ¦  «        ¦  «        }n¶# t          $ r!}t          d|› d| j        ›d�¦  «        |‚d}~wt          j        $ r(}t          d|› d|› �¦  «        t%          |¦  «        ‚d}~wt&          $ r!}t          d|› d|j        › d�¦  «        d‚d}~wt          t*          f$ r}t          d|› d|› �¦  «        |‚d}~ww xY w|                     d¦  «        }|�Q|t.          k    rF| j        €J ‚| j        d                              d¦  «        }t          d|›dt.          ›d|›�¦  «        ‚|S )u‘  Read the credentials file. Re-reads on every call â€” daemons rotate it.

        Secret values in the returned dict (every string field not in
        ``_secrets._PLAIN_KEYS``) are :class:`SecretStr`-wrapped â€” unwrap
        with ``_unwrap_secret`` at the point of use. Writing the dict back
        through :meth:`_atomic_write_credentials` unwraps automatically.

        On Unix, verifies the file is not group/world-readable. World-readable
        credentials files are refused outright; group-readable files log a
        warning but are accepted. The check is skipped on Windows where POSIX
        mode bits don't carry the same meaning.
        NÚposixF)Úfollow_symlinkszCredentials file not found at r¬   ú).úCredentials file at z could not be accessed: zu is a symlink; refusing to follow (move the real file into place to keep secret material on the expected filesystem).é   z is world-readable (mode z#oz); run `chmod 600 z` before retrying.é8   zMCredentials file at %s is group-readable (mode %#o); consider `chmod 600 %s`.r©   rª   r®   r¯   r°   r­   rX   r±   zcredentials file has type z; expected z for authentication.type )r†   rP   ÚnameÚstatr¶   r+   r€   r·   ÚS_ISLNKÚst_modeÚS_IMODEr,   Úwarningr   r¹   rº   rµ   r»   r   r   Ú	type_namer¸   rO   ÚCREDENTIALS_FILE_TYPEr…   )rg   r^   Ú	file_statr=   ÚmodeÚcredsÚactualra   s           r?   Ú_read_credentialsz!CredentialsFile._read_credentialse  s  € ð Ô%Ð1Ð1Ð1ØÔ%ˆÝŒ7�gÒÐðjÝœG D¸%Ð@Ñ@Ô@�	�	øÝ$ð tð tð tÝ$Ð%iÀdÐ%iÐ%iÐVZÔVcÐ%iÐ%iÐ%iÑjÔjÐpsÐsøøøøÝð jð jð jÝ$Ð%_¸DÐ%_Ð%_ÐZ]Ð%_Ð%_Ñ`Ô`ÐfiÐiøøøøðjøøøåŒ|˜IÔ-Ñ.Ô.ð Ý$ðk¨4ð kð kð kñô ð õ ”< 	Ô 1Ñ2Ô2ˆDØ�e‰|ð Ý$ð?¨4ð ?ð ?È$ÐVð ?ð ?Ø&*ð?ð ?ð ?ñô ð ð �e‰|ð Ý—’ØcØØØñ	ô ð ð	bõ
 %8½¼
À4Ç>Â>Ð[bÀ>ÑCcÔCcÑ8dÔ8dÑ$eÔ$eˆEˆEøÝ ð 	pð 	pð 	pÝ Ð!eÀ$Ð!eÐ!eÐRVÔR_Ð!eÐ!eÐ!eÑfÔfÐloÐoøøøøÝÔ#ð 	tð 	tð 	tå Ð!W¸Ð!WÐ!WÐRUÐ!WÐ!WÑXÔXÕ^nÐorÑ^sÔ^sÐsøøøøÝ%ð 	ð 	ð 	õ !Ø^ tÐ^Ð^ÈcÌmÐ^Ð^Ð^ñô àðøøøøõ Õ+Ð,ð 	bð 	bð 	bÝ Ð!W¸Ð!WÐ!WÐRUÐ!WÐ!WÑXÔXÐ^aÐaøøøøð	bøøøð
 —’˜6Ñ"Ô"ˆØÐ &Õ,AÒ"AÐ"AØ”<Ð+Ð+Ð+ØœÐ%5Ô6×:Ò:¸6ÑBÔBˆIÝ ð9¨Vð 9ð 9ÕBWð 9ð 9Ø+4ð9ð 9ñô ð ð ˆs]   ¢9 ¹
BÁAÁBÁ,BÂBÄ5E Å
G:ÅE-Å-G:Å?#F"Æ"G:Æ/GÇG:ÇG5Ç5G:úhttpx.Clientc                óx   — | j         �| j         S | j        €t          j        t          ¬¦  «        | _        | j        S )zFReturn an ``httpx.Client``, lazily creating (and tracking) one we own.N)Útimeout)rƒ   r„   ÚhttpxÚClientr    rŠ   s    r?   rŸ   z CredentialsFile._get_http_client­  s<   € àÔÐ(ØÔ$Ð$ØÔ"Ð*Ý&+¤lÕ;QÐ&RÑ&RÔ&RˆDÔ#ØÔ&Ð&rT   c                ó˜   — | j         � | j                              ¦   «          d| _         | j        �| j                             ¦   «          dS dS )z3Close the owned ``httpx.Client`` if we created one.N)r„   Úcloserˆ   rŠ   s    r?   rÝ   zCredentialsFile.closeµ  sT   € àÔ"Ð.ØÔ#×)Ò)Ñ+Ô+Ð+Ø&*ˆDÔ#ØÔ"Ð.ØÔ#×)Ò)Ñ+Ô+Ð+Ð+Ð+ð /Ð.rT   c                ó"   — d| _         d| _        dS )aÌ  Drop the cached config so the next call re-reads it from disk.

        ``CredentialsFile`` caches the parsed config across calls to keep the
        hot path cheap; a daemon that rotates a profile in place (e.g. flips
        ``"type": "user_oauth"`` to ``"type": "oidc_federation"``) will not be
        picked up automatically. Callers that need to react to such changes
        can call ``reload()`` to force a fresh read on the next ``__call__``.
        N)r…   rˆ   rŠ   s    r?   ÚreloadzCredentialsFile.reload½  s   € ð ˆŒØ"&ˆÔÐÐrT   Údatac                ó0  — | j         €J ‚| j         j        }|                     ddd¬¦  «         t          j        |d| j         j        › d�d¬¦  «        \  }}	 	 t          j        |d¦  «         t          j        |t          |d	¬
¦  «        ¦  «         t          j
        |¦  «         t          j        |¦  «         n# t          j        |¦  «         w xY wt          j        || j         ¦  «         n5# t          $ r( 	 t          j        |¦  «         n# t          $ r Y nw xY w‚ w xY w	 t          j        |t          j        ¦  «        }	 t          j
        |¦  «         t          j        |¦  «         dS # t          j        |¦  «         w xY w# t          $ r Y dS w xY w)ai  Atomic write to the credentials file (NOT the config file).

        ``data`` may hold :class:`SecretStr` token values (see
        :meth:`_read_credentials`); they are unwrapped at dump time, so the
        on-disk format is unchanged and this frame's locals stay redacted if
        the write fails (e.g. ENOSPC) with a crash reporter capturing them.
        NTiÀ  )ÚparentsÚexist_okrÓ   r°   z.tmp)ÚdirÚprefixÚsuffixi€  é   )Úindent)r†   ÚparentÚmkdirÚtempfileÚmkstemprÊ   rP   ÚfchmodÚwriter   ÚfsyncrÝ   ÚreplaceÚBaseExceptionÚunlinkr·   ÚopenÚO_RDONLY)rg   rà   ré   ÚfdÚtmpÚdir_fds         r?   Ú_atomic_write_credentialsz)CredentialsFile._atomic_write_credentialsÉ  sµ  € ð Ô%Ð1Ð1Ð1ØÔ'Ô.ˆØ�Š˜T¨D°uˆÑ=Ô=Ð=õ
 Ô" vÐ6X¸$Ô:PÔ:UÐ6XÐ6XÐ6XÐagÐhÑhÔh‰ˆˆCð	ðÝ”	˜"˜eÑ$Ô$Ð$Ý”˜Õ0°¸aÐ@Ñ@Ô@ÑAÔAÐAÝ”˜‘”�å”˜‘”��ø•”˜‘”��øøøÝŒJ�s˜DÔ2Ñ3Ô3Ð3Ð3øÝð 	ð 	ð 	ðÝ”	˜#‘”��øÝð ð ð Ø�ðøøøàð	øøøð	Ý”W˜V¥R¤[Ñ1Ô1ˆFð!Ý”˜Ñ Ô Ð å”˜Ñ Ô Ð Ð Ð ø•”˜Ñ Ô Ð Ð øøøøÝð 	ð 	ð 	ØˆDˆDð	øøøsm   ÁAB: Â%C. Â:CÃC. Ã.
D Ã9DÄD Ä
DÄD ÄDÄD Ä$F ÅE. ÅF Å.FÆF Æ
FÆFc                óV   — |                       ¦   «         }t          d|d         ¦  «        S )zEReturn the cached ``authentication`` sub-object from the config file.rE   r±   )r�   r	   r£   s     r?   r�   zCredentialsFile._auth_blockõ  s*   € à×"Ò"Ñ$Ô$ˆÝÐ$ fÐ-=Ô&>Ñ?Ô?Ð?rT   Fri   rj   rk   r   c               ó2  — |                       ¦   «         }|                     d¦  «        }|t          k    r|                      ||¬¦  «        S |t          k    r|                      ||¬¦  «        S t          d|›d| j        › dt          ›dt          ›d�	¦  «        ‚)NrX   ri   úUnknown authentication.type ú at ú. Expected ú or r°   )r�   rO   r_   Ú_call_oidc_federationr`   Ú_call_user_oauthr+   r�   )rg   rj   rF   ra   s       r?   ro   zCredentialsFile.__call__ú  sÉ   € Ø×ÒÑ!Ô!ˆØ—H’H˜VÑ$Ô$ˆ	àÕ1Ò1Ð1Ø×-Ò-¨dÀ-Ð-ÑPÔPÐPàÕ,Ò,Ð,Ø×(Ò(¨¸]Ð(ÑKÔKÐKåðS¨9ð Sð S¸DÔ<Mð Sð SÝ1ðSð SÝ9MðSð Sð Sñ
ô 
ð 	
rT   rF   c               ó:  — ddl m}m}m} |                      ¦   «         }|                     d¦  «        }|st          d| j        › d�¦  «        ‚|                     d¦  «        }|sFt          |                     d¦  «        | j        ¦  «        }	t          t          |¦  «        |	¬¦  «        S |                     d	¦  «        }
|
s# |d
| j        ›dt          ›d| j        › �¦  «        ‚t          |                     d¦  «        | j        ¦  «        }	|s7|	�5t          j        ¦   «         |	k     rt          t          |¦  «        |	¬¦  «        S t          |
|dœ}	 |                      ¦   «                              | j        › t$          › �t'          |¦  «        dt(          t+          ¦   «         dœ¬¦  «        }n3# t,          j        $ r!} |d|› �¦  «        t1          |¦  «        ‚d}~ww xY w|j        dk    r ||d¬¦  «         	 t5          |                     ¦   «         ¦  «        }n€# t8          $ r8} |d|j        › d�|j         ||¦  «        ¬¦  «        t1          |¦  «        ‚d}~wt:          $ r3} |d|j        › d|j        › d�|j         ||¦  «        ¬¦  «        d‚d}~ww xY w|                     d¦  «        }|s |d¦  «        ‚|                     dd¦  «        }	 t?          |¦  «        }n)# t@          t8          f$ r} |d|›d �¦  «        |‚d}~ww xY wt?          t          j        ¦   «         ¦  «        |z   }|                     d	¦  «        p|
}tB          |d!<   tD          |d"<   ||d<   ||d<   ||d	<   |  #                    |¦  «         t          t          |¦  «        |¬¦  «        S )#zÞInteractive-login profile. With a ``client_id`` in the auth block,
        we run the refresh_token grant on expiry; without one, we treat the
        credentials file as externally rotated and just read it fresh.
        r   )ÚWorkloadIdentityErrorÚ_request_idÚ_raise_token_endpoint_errorÚaccess_tokenrÇ   z is missing 'access_token'.Ú	client_idrn   rm   Úrefresh_tokenzcredentials file for profile z (authentication.type z/ with client_id) must include 'refresh_token': N)Ú
grant_typer  r  zapplication/json)zContent-Typezanthropic-betaz
User-Agent)Úcontentr¦   z3user_oauth refresh failed to reach token endpoint: éÈ   zuser_oauth refresh failed)Úmessage_prefixz8user_oauth refresh returned a non-JSON response (status rÆ   )Ústatus_codeÚ
request_idz#user_oauth refresh returned a JSON z	 (status z); expected an object.z2user_oauth refresh response missing 'access_token'Ú
expires_ini  z5user_oauth refresh response has invalid 'expires_in' z(; expected an integer number of seconds.ÚversionrX   )$Ú	_workloadr  r  r  rÖ   rO   r+   r†   r@   r   r   r€   r`   Útimer"   rŸ   Úpostr‡   r   r   r   r$   rÚ   Ú	HTTPErrorr   r  r   r¹   r<   r   rÐ   r:   r;   ÚCREDENTIALS_FILE_VERSIONrÑ   rø   )rg   rF   rj   r  r  r  rÔ   r  r  rn   r  ÚbodyÚrespr=   ÚpayloadÚ
new_accessÚraw_expires_inr  Únew_expires_atÚnew_refreshs                       r?   r   z CredentialsFile._call_user_oauth  s�  € ð
 	_Ð^Ð^Ð^Ð^Ð^Ð^Ð^Ð^Ð^à×&Ò&Ñ(Ô(ˆØ—y’y Ñ0Ô0ˆØð 	mÝ Ð!k¸Ô8NÐ!kÐ!kÐ!kÑlÔlÐlà—H’H˜[Ñ)Ô)ˆ	Øð 	Zõ ,¨E¯IªI°lÑ,CÔ,CÀTÔE[Ñ\Ô\ˆJÝ¥^°LÑ%AÔ%AÈjÐYÑYÔYÐYàŸ	š	 /Ñ2Ô2ˆØð 	Ø'Ð'ð,°´ð ,ð ,Ý'ð,ð ,àÔ)ð,ð ,ñô ð õ (¨¯	ª	°,Ñ(?Ô(?ÀÔAWÑXÔXˆ
Øð 	Z Ð!7½D¼I¹K¼KÈ*Ò<TÐ<TÝ¥^°LÑ%AÔ%AÈjÐYÑYÔYÐYõ 3Ø*Ø"ð2
ð 2
ˆð	)Ø×(Ò(Ñ*Ô*×/Ò/Ø”>Ð3¥>Ð3Ð3õ ,¨DÑ1Ô1à$6õ
 '<Ý"-¡-¤-ðð ð 0ñ ô ˆDˆDøõ Œð 	)ð 	)ð 	)Ø'Ð'ØKÀcÐKÐKñô å# CÑ(Ô(ð)øøøøð	)øøøð
 Ô˜sÒ"Ð"Ø'Ð'¨Ð=XÐYÑYÔYÐYð	Ý&9¸$¿)º)¹+¼+Ñ&FÔ&FˆGˆGøÝð 	)ð 	)ð 	)ð (Ð'Ø_È4ÔK[Ð_Ð_Ð_Ø Ô,Ø&˜; tÑ,Ô,ðñ ô õ $ CÑ(Ô(ð	)øøøøõ
 &ð 	ð 	ð 	ð (Ð'Øv°c´mÐvÐvÈdÔN^ÐvÐvÐvØ Ô,Ø&˜; tÑ,Ô,ðñ ô ð ð	øøøøð	øøøð —[’[ Ñ0Ô0ˆ
Øð 	^Ø'Ð'Ð(\Ñ]Ô]Ð]Ø Ÿš \°4Ñ8Ô8ˆð	Ý˜^Ñ,Ô,ˆJˆJøÝ�:Ð&ð 	ð 	ð 	Ø'Ð'ð:Èð :ð :ð :ñô ð ðøøøøð	øøøõ
 �TœY™[œ[Ñ)Ô)¨JÑ6ˆØ—k’k /Ñ2Ô2ÐC°mˆå3ˆˆiÑÝ-ˆˆf‰Ø *ˆˆnÑØ,ˆˆlÑØ!,ˆˆoÑð 	×&Ò& uÑ-Ô-Ð-å¥°
Ñ!;Ô!;ÈÐWÑWÔWÐWsU   ÅAF- Æ-GÆ<GÇGÇ9!H È
JÈ%3IÉJÉ%.JÊJËK$ Ë$L
Ë5LÌL
úOptional[Dict[str, Any]]c                óÚ   — | j         €J ‚| j                              ¦   «         sdS 	 |                      ¦   «         S # t          $ r&}t	          |j        t          ¦  «        rY d}~dS ‚ d}~ww xY w)uÑ   ``_read_credentials`` variant that returns ``None`` on absence
        instead of raising â€” used by the federation disk-cache path where a
        missing credentials file just means "exchange now".
        N)r†   ÚexistsrÖ   r+   r¼   Ú	__cause__r¶   )rg   r=   s     r?   Ú_read_credentials_if_existsz+CredentialsFile._read_credentials_if_exists{  sŠ   € ð
 Ô%Ð1Ð1Ð1ØÔ%×,Ò,Ñ.Ô.ð 	Ø�4ð	Ø×)Ò)Ñ+Ô+Ð+øÝð 	ð 	ð 	Ý˜#œ-Õ):Ñ;Ô;ð Ø�t�t�t�t�tØøøøøð	øøøs   ¦: º
A*ÁA%Á$A%Á%A*c               ó  — | j         €|                      |¦  «        | _         | j        €|                       ¦   «         S |                      ¦   «         }|s­|�«|                     d¦  «        }|                     d¦  «        }	 |rf|�dt          j        ¦   «         t          |¦  «        t          z
  k     r8t          t          t          |¦  «        ¦  «        t          |¦  «        ¬¦  «        S n# t          t          f$ r Y nw xY w|                       ¦   «         }	 |                      i |pi ¥t          t           t#          |j        ¦  «        |j        dœ¥¦  «         n2# t(          $ r%}t*                               d|¦  «         Y d }~nd }~ww xY w|S )Nr  rn   rm   )r  rX   r  rn   z?federation token disk-cache write-back failed (best-effort): %s)rˆ   Ú_build_workload_delegater†   r   rO   r  Úfloatr#   r   rK   r   r:   r;   r<   rø   r  rÑ   r   rd   rn   r·   r,   Údebug)rg   rF   rj   Úcachedr  rn   rd   r=   s           r?   rÿ   z%CredentialsFile._call_oidc_federationŠ  sÆ  € ØÔ"Ð*Ø&*×&CÒ&CÀDÑ&IÔ&IˆDÔ#ð Ô!Ð)Ø×*Ò*Ñ,Ô,Ð,ð ×1Ò1Ñ3Ô3ˆØð 	 Ð!3Ø!Ÿ:š: nÑ5Ô5ˆLØŸš LÑ1Ô1ˆJð	à ðlà"Ð.Ýœ	™œ¥e¨JÑ&7Ô&7Õ:SÑ&SÒSÐSå&­SµÀÑ1MÔ1MÑ-NÔ-NÕ[^Ð_iÑ[jÔ[jÐkÑkÔkÐkøøÝ�zÐ*ð ð ð à�ðøøøð ×'Ò'Ñ)Ô)ˆð	^Ø×*Ò*ðØ�| ðå7Ý1õ %.¨e¬kÑ$:Ô$:Ø"'Ô"2ðð ð ñ
ô 
ð 
ð 
øõ ð 	^ð 	^ð 	^Ý�IŠIÐWÐY\Ñ]Ô]Ð]Ð]Ð]Ð]Ð]Ð]øøøøð	^øøøàˆs,   Â A'C) Ã)C=Ã<C=ÄAE Å
FÅ!FÆFr-   c           
     óþ  — ddl m}m} |                     d¦  «        }| j        €J ‚| j                             d¦  «        }|r|s |dt
          ›d| j        › �¦  «        ‚|                     d¦  «        }|�i|                     d¦  «        }|d	k    rt          d
|›d�¦  «        ‚|                     d¦  «        }|s#t          d| j        ›d| j        › d|›d�¦  «        ‚nd }|rt          |¦  «        nt          ¦   «         }	 ||	|||                     d¦  «        | j                             d¦  «        |                     d¦  «        |  
                    ¦   «         ¬¦  «        }
|
                     | j        ¦  «         |
S )Nr   ©r  r-   rY   rV   z%config file with authentication.type zS must include 'authentication.federation_rule_id' and top-level 'organization_id': r\   r4   r]   zidentity_token source z- is not supported; only 'file' is implementedr^   z@identity_token source 'file' requires a non-empty path; profile rü   z has identity_token=r°   rZ   rW   r[   ©Úidentity_token_providerrY   rV   rZ   rW   r[   r{   )r  r  r-   rO   r…   r_   r�   r+   r€   r2   rŸ   rš   r‡   )rg   rF   r  r-   rY   rV   Úidentity_token_cfgr4   Úidentity_token_pathr    Údelegates              r?   r"  z(CredentialsFile._build_workload_delegateº  s  € ð 	RÐQÐQÐQÐQÐQÐQÐQà!ŸXšXÐ&:Ñ;Ô;ÐØŒ|Ð'Ð'Ð'Øœ,×*Ò*Ð+<Ñ=Ô=ˆØ!ð 	¨ð 	Ø'Ð'ð'Õ8Qð 'ð 'àÔ$ð'ð 'ñô ð ð "ŸXšXÐ&6Ñ7Ô7ÐØÐ)Ø'×+Ò+¨HÑ5Ô5ˆFØ˜ÒÐÝ$Ð%u¸fÐ%uÐ%uÐ%uÑvÔvÐvØ"4×"8Ò"8¸Ñ"@Ô"@ÐØ&ð 	õ %ðsØ#œ}ðsð sØ48Ô4Eðsð sØ[mðsð sð sñô ð ð	ð #'ÐØ=PÐiÕ$Ð%8Ñ9Ô9Ð9ÕVgÑViÔViˆð
 /Ð.Ø$,Ø1Ø+Ø#ŸxšxÐ(<Ñ=Ô=Øœ×)Ò)¨.Ñ9Ô9Ø—(’(˜7Ñ#Ô#Ø×-Ò-Ñ/Ô/ð
ñ 
ô 
ˆð 	×Ò˜tœ~Ñ.Ô.Ð.ØˆrT   rN   )r|   r}   r{   r~   r6   rG   ©r6   rK   ©r6   r‹   )r6   r}   )rU   rK   r6   rG   )rU   rK   r6   r›   )rD   rE   r6   rK   )r6   r¤   ©r6   rE   )r6   r×   ©r6   rG   )rà   rE   r6   rG   rp   )rF   rE   rj   rk   r6   r   )r6   r  ©rF   rE   r6   r-   )rq   rr   rs   rt   rh   Úpropertyr|   r�   r“   rš   r¡   r˜   r§   r�   rÖ   rŸ   rÝ   rß   rø   r�   ro   r   r   rÿ   r"  ru   rT   r?   r0   r0   ’   sA  € € € € € ð'ð 'ðV "&ðNð /3ð	Nð Nð Nð Nð Nð Nð& ðð ð ñ „Xðð ð!ð !ð !ñ „Xð!ð ð5ð 5ð 5ñ „Xð5ðSð Sð Sð Sð"ð ð ð ð:
 ð 
 ð 
 ð 
 ðð ð ð ð&1ð 1ð 1ð 1ðfFð Fð Fð FðP'ð 'ð 'ð 'ð,ð ,ð ,ð ,ð
'ð 
'ð 
'ð 
'ð(ð (ð (ð (ðX@ð @ð @ð @ð
 16ð 
ð 
ð 
ð 
ð 
ð 
ð" OTð lXð lXð lXð lXð lXð lXð`ð ð ð ð TYð .ð .ð .ð .ð .ð .ð`3ð 3ð 3ð 3ð 3ð 3rT   r0   c                  ó<   — e Zd ZdZddd„Zedd	„¦   «         Zdd„ZdS )r2   zïAn :class:`IdentityTokenProvider` that reads a JWT from a file on every call.

    Kubernetes projected service-account tokens (and similar) are rotated in place,
    so the file MUST be re-read on every invocation rather than cached.
    Nr^   ú$Union[str, 'os.PathLike[str]', None]r6   rG   c                óf   — t          |¦  «        }|€t          dt          › d�¦  «        ‚|| _        d S )Nz;No identity token file path given. Pass `path=` or set the z environment variable.)r)   r+   r!   Ú_path)rg   r^   Úresolveds      r?   rh   zIdentityTokenFile.__init__÷  sK   € Ý.¨tÑ4Ô4ˆØÐÝ ð)ÕNeð )ð )ð )ñô ð ð ˆŒ
ˆ
ˆ
rT   r‹   c                ó   — | j         S rN   )r6  rŠ   s    r?   r^   zIdentityTokenFile.path   s
   € àŒzÐrT   rK   c                óê  — 	 | j                              d¬¦  «                             ¦   «         }n©# t          $ r}t	          d| j         › d�¦  «        |‚d }~wt
          $ r!}t	          d| j         › d|› d�¦  «        |‚d }~wt          $ r}t	          d| j         › d	�¦  «        |‚d }~wt          t          f$ r }t	          d| j         › d
|› �¦  «        |‚d }~ww xY w|st	          d| j         › d�¦  «        ‚|S )Nr©   rª   z!Identity token file not found at r°   zIdentity token file at z" is not readable by this process: z;. Check the file mode and the effective uid of the process.zIdentity token path zF is a directory, not a file. Point at the projected token file itself.r­   z‹ is empty. If this is a Kubernetes projected service-account token, check the volume mount and the serviceAccountToken projection audience.)	r6  rµ   Ústripr¶   r+   ÚPermissionErrorÚIsADirectoryErrorr·   r¸   )rg   r	  r=   s      r?   ro   zIdentityTokenFile.__call__  s’  € ð	kØ”j×*Ò*°GÐ*Ñ<Ô<×BÒBÑDÔDˆGˆGøÝ ð 	]ð 	]ð 	]Ý Ð!RÀTÄZÐ!RÐ!RÐ!RÑSÔSÐY\Ð\øøøøÝð 	ð 	ð 	Ý ðM¨$¬*ð Mð MÐX[ð Mð Mð Mñô ð ðøøøøõ !ð 	ð 	ð 	Ý ð= t¤zð =ð =ð =ñô ð ðøøøøõ Õ+Ð,ð 	kð 	kð 	kÝ Ð!`¸4¼:Ð!`Ð!`Ð[^Ð!`Ð!`ÑaÔaÐgjÐjøøøøð	køøøàð 	Ý ðQ¨$¬*ð Qð Qð Qñô ð ð
 ˆs8   ‚-0 °
CºAÁCÁ A<Á<CÂ	B"Â"CÂ6CÃCrN   )r^   r4  r6   rG   r.  r-  )rq   rr   rs   rt   rh   r2  r^   ro   ru   rT   r?   r2   r2   ð  sk   € € € € € ðð ðð ð ð ð ð ðð ð ñ „Xððð ð ð ð ð rT   r2   c                  ó”   ‡ — e Zd ZdZ ej        d¦  «        Zdddœdd„Zedd„¦   «         Z	edd„¦   «         Z
edˆ fd„¦   «         Zˆ xZS )r1   uÆ  An :class:`AccessTokenProvider` driven by an in-memory config dict
    (same shape as ``configs/<profile>.json``) rather than files on disk.

    Intended for callers that want to construct an :class:`anthropic.Anthropic`
    client with a fully programmatic credentials setup â€” equivalent to the Go
    SDK's ``option.WithConfig`` / TypeScript SDK's ``ClientOptions.config``.

    Both ``authentication.type`` discriminator values are supported:

    ``"oidc_federation"``
        ``authentication.credentials_path`` is **optional**. If set, exchanged
        tokens are cached to / read from that file (same atomic 0600 write as
        :class:`CredentialsFile`). If omitted, every call performs a fresh
        jwt-bearer exchange with no on-disk cache.

    ``"user_oauth"``
        ``authentication.credentials_path`` is **required** â€” it is where the
        access/refresh tokens live. Behaviour is identical to a file-backed
        :class:`CredentialsFile` profile of the same shape.

    The implementation subclasses :class:`CredentialsFile` so the dispatch,
    refresh-grant, disk-cache and atomic-write logic are shared verbatim;
    only config loading and identity-token resolution are overridden.
    z<in-memory config>N)r)  r{   rD   rE   r)  úOptional[IdentityTokenProvider]r{   r~   r6   rG   c          	     ó  — |                      d¦  «        }t          |t          ¦  «        s t          dt          › dt
          › d�¦  «        ‚t          d|¦  «        }|                      d¦  «        }|t          t
          fvr#t          d|›dt          ›d	t
          ›d
�¦  «        ‚|                      d¦  «        }|t
          k    r|st          dt
          ›d�¦  «        ‚d| _        | j        | _	        d | _
        || _        d | _        d | _        || _        || _        |r3t!          j        t%          |¦  «        ¦  «                             ¦   «         nd | _        |                      |¦  «        | _        t/          | j        d¬¦  «         d S )Nr±   zaconfig dict is missing the 'authentication' object. Expected shape: {"authentication": {"type": "r²   r³   rE   rX   rû   rý   rþ   r°   r´   zauthentication.type zŽ requires 'authentication.credentials_path' (where the access/refresh tokens live). For profile-based resolution, use CredentialsFile instead.z<in-memory>zconfig: base_urlr–   )rO   r¼   r½   r+   r_   r`   r	   r€   Ú_IN_MEMORY_PATHr�   r‚   rƒ   r„   rˆ   Ú!_identity_token_provider_overrider…   r¾   r¿   rK   rÀ   r†   r˜   r‡   r%   )rg   rD   r)  r{   rÂ   rF   ra   r´   s           r?   rh   zInMemoryConfig.__init__:  s×  € ð —:’:Ð.Ñ/Ô/ˆÝ˜(¥DÑ)Ô)ð 	Ý ð;ÝB[ð;ð ;å)ð;ð ;ð ;ñô ð õ
 Ð$ hÑ/Ô/ˆØ—H’H˜VÑ$Ô$ˆ	ØÕ6Õ8LÐMÐMÐMÝ ðW¨yð Wð WÝ5ðWð WÝ=QðWð Wð Wñô ð ð
  Ÿ8š8Ð$6Ñ7Ô7ÐØÕ,Ò,Ð,Ð5EÐ,Ý ðNÕ';ð Nð Nð Nñô ð ð &ˆŒØ Ô0ˆÔØ.2ˆÔØ'ˆÔØ:>ˆÔØIMˆÔØ1HˆÔ.àˆŒØUeÐ!o¥¤­cÐ2BÑ.CÔ.CÑ!DÔ!D×!OÒ!OÑ!QÔ!QÐ!QÐkoˆÔØ×/Ò/°Ñ7Ô7ˆŒÝ�t”~Ð-?Ð@Ñ@Ô@Ð@Ð@Ð@rT   c                ó"   — | j         €J ‚| j         S rN   )r…   rŠ   s    r?   r�   zInMemoryConfig._load_configg  s   € àŒ|Ð'Ð'Ð'ØŒ|ÐrT   c                ó   — d | _         d S rN   )rˆ   rŠ   s    r?   rß   zInMemoryConfig.reloadl  s   € ð #'ˆÔÐÐrT   rF   r-   c           
     ó
  •— | j         €!t          ¦   «                              |¦  «        S ddlm}m} |                     d¦  «        }| j        €J ‚| j                             d¦  «        }|r|s |dt          ›d�¦  «        ‚ || j         |||                     d¦  «        | j                             d¦  «        |                     d	¦  «        |  	                    ¦   «         ¬
¦  «        }| 
                    | j        ¦  «         |S )Nr   r'  rY   rV   z%config dict with authentication.type zQ must include 'authentication.federation_rule_id' and top-level 'organization_id'rZ   rW   r[   r(  )rA  Úsuperr"  r  r  r-   rO   r…   r_   rŸ   rš   r‡   )rg   rF   r  r-   rY   rV   r,  Ú	__class__s          €r?   r"  z'InMemoryConfig._build_workload_delegater  s5  ø€ àÔ1Ð9Ý‘7”7×3Ò3°DÑ9Ô9Ð9àQÐQÐQÐQÐQÐQÐQÐQà!ŸXšXÐ&:Ñ;Ô;ÐØŒ|Ð'Ð'Ð'Øœ,×*Ò*Ð+<Ñ=Ô=ˆØ!ð 	¨ð 	Ø'Ð'ðWÕ8Qð Wð Wð Wñô ð ð /Ð.Ø$(Ô$JØ1Ø+Ø#ŸxšxÐ(<Ñ=Ô=Øœ×)Ò)¨.Ñ9Ô9Ø—(’(˜7Ñ#Ô#Ø×-Ò-Ñ/Ô/ð
ñ 
ô 
ˆð 	×Ò˜tœ~Ñ.Ô.Ð.ØˆrT   )rD   rE   r)  r>  r{   r~   r6   rG   r/  r0  r1  )rq   rr   rs   rt   r¾   r¿   r@  rh   r
   r�   rß   r"  Ú__classcell__)rF  s   @r?   r1   r1     sÖ   ø€ € € € € ðð ð2 #�g”lÐ#7Ñ8Ô8€Oð DHØ.2ð+Að +Að +Að +Að +Að +AðZ ðð ð ñ „Xðð ð'ð 'ð 'ñ „Xð'ð
 ðð ð ð ð ñ „Xðð ð ð ð rT   r1   )r3   r   r4   r5   r6   r7   )rD   rE   rF   rE   r6   rG   )JÚ
__future__r   rP   rž   r¹   rË   r  Úloggingr¾   rë   Útypingr   r   r   r   r   r	   Útyping_extensionsr
   rÚ   Ú_typesr   r   Ú_secretsr   r   r   r   r   r   Ú
_constantsr   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   Ú_exceptionsr+   Ú	getLoggerrq   r,   Ú__annotations__r  r-   Ú__all__r@   rÑ   ÚCONFIG_FILE_VERSIONr  r_   r`   rb   r.   r/   r0   r2   r1   ru   rT   r?   ú<module>rT     s�  ðØ "Ð "Ð "Ð "Ð "Ð "Ð "à 	€	€	€	Ø €€€Ø €€€Ø €€€Ø €€€Ø €€€Ø €€€Ø €€€Ø BÐ BÐ BÐ BÐ BÐ BÐ BÐ BÐ BÐ BÐ BÐ BÐ BÐ BÐ BÐ BØ &Ð &Ð &Ð &Ð &Ð &à €€€à 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð0 *Ð )Ð )Ð )Ð )Ð )à'�gÔ'¨Ñ1Ô1€Ð 1Ð 1Ð 1Ñ 1àð 7Ø6Ð6Ð6Ð6Ð6Ð6à
_Ð
_Ð
_€ðð ð ð ð" &Ð ð Ð Ø Ð ð .Ð Ø#Ð ð'ð 'ð 'ð 'ð>?ð ?ð ?ð ?ð ?ñ ?ô ?ð ?ð9ð 9ð 9ð 9ð 9ñ 9ô 9ð 9ð"[	ð [	ð [	ð [	ð [	ñ [	ô [	ð [	ð|+ð +ð +ð +ð +ñ +ô +ð +ð\mð mð mð mð m�_ñ mô mð mð mð mrT   