§
    ÜŽ’jA  ã                  ó¦   — d dl mZ d dlZd dlmZmZmZmZ d dlm	Z	 g d¢Z
 G d„ de¦  «        Z ed¦  «        Zdd„Zdd„Zdd„Zddœdd„Zdd„ZdS )é    )ÚannotationsN)ÚAnyÚDictÚOptionalÚcast)Ú	SecretStr)r   Ú_NonObjectPayloadErrorÚ_wrap_secret_fieldsÚ_unwrap_secretÚ_json_dumps_secretsÚ_strip_tracebackc                  ó$   ‡ — e Zd ZdZdˆ fd„Zˆ xZS )r	   u  Raised by :func:`_wrap_secret_fields` for JSON payloads that are not
    objects. Carries only the payload's type name â€” a non-object payload can
    be an echo of the request (assertion included), so it must never bind in
    a caller's frame or ride along in an exception.
    Ú	type_nameÚstrÚreturnÚNonec                ó^   •— t          ¦   «                              d|› �¦  «         || _        d S )Nzexpected a JSON object, got )ÚsuperÚ__init__r   )Úselfr   Ú	__class__s     €úPC:\Projects\DSCons\.venv\Lib\site-packages\anthropic\lib\credentials\_secrets.pyr   z_NonObjectPayloadError.__init__   s/   ø€ Ý‰Œ×ÒÐC¸	ÐCÐCÑDÔDÐDØ"ˆŒˆˆó    )r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__classcell__)r   s   @r   r	   r	      sG   ø€ € € € € ðð ð#ð #ð #ð #ð #ð #ð #ð #ð #ð #r   r	   )	ÚtypeÚversionÚ
expires_atÚ
token_typeÚ
expires_inÚscopeÚerrorÚerror_descriptionÚ	error_uriÚpayloadr   r   úDict[str, Any]c                ó4  — t          | t          ¦  «        s$t          | ¦  «        j        }~ t	          |¦  «        ‚t          d| ¦  «        }|D ]K}|t          vr@t          |                     |¦  «        t          ¦  «        rt          ||         ¦  «        ||<   ŒL|S )ui  Wrap the secret fields of a parsed JSON object in ``SecretStr``.

    Called at every boundary where credential material enters SDK code.
    Traceback frames retain their locals, so any dict a raise site (or a
    frame an error merely propagates through) still holds must already be
    redacted â€” ``SecretStr`` renders as ``SecretStr('**********')`` under
    crash reporters that capture and render locals.

    String values are secret unless their key is in ``_PLAIN_KEYS``; wrapped
    empty strings stay falsy (``SecretStr`` defines ``__len__`` across the
    supported pydantic range), so ``if not creds.get("access_token")`` checks
    behave unchanged. Only top-level values are wrapped â€” the credential
    formats are flat; revisit if a nested shape ever appears. Mutates
    ``payload`` in place â€” a copy would leave the raw-valued original
    reachable â€” and returns it.

    Non-object payloads raise :class:`_NonObjectPayloadError` from this frame,
    with the payload unbound first, so the raw value never lands in any frame
    of the traceback â€” callers translate to their own redacted error.
    r)   )
Ú
isinstanceÚdictr   r   r	   r   Ú_PLAIN_KEYSÚgetr   r   )r(   r   ÚmappingÚkeys       r   r
   r
   3   s•   € õ* �g�tÑ$Ô$ð 0Ý˜‘M”MÔ*ˆ	ØÝ$ YÑ/Ô/Ð/ÝÐ# WÑ-Ô-€GØð 3ð 3ˆØ•kÐ!Ð!¥j°·²¸SÑ1AÔ1AÅ3Ñ&GÔ&GÐ!Ý$ W¨S¤\Ñ2Ô2ˆG�C‰LøØ€Nr   Úvaluec                óX   — t          | t          ¦  «        r|                      ¦   «         n| S )z�Inverse of :func:`_wrap_secret_fields` for a single value; pass-through
    for values that were never wrapped (absent or non-string fields).)r+   r   Úget_secret_value©r1   s    r   r   r   S   s*   € õ (2°%½Ñ'CÔ'CÐNˆ5×!Ò!Ñ#Ô#Ð#ÈÐNr   c                óž   — t          | t          ¦  «        r|                      ¦   «         S t          dt	          | ¦  «        j        › d�¦  «        ‚)NzObject of type z is not JSON serializable)r+   r   r3   Ú	TypeErrorr   r   r4   s    r   Ú_json_defaultr7   Y   sI   € Ý�%�Ñ#Ô#ð (Ø×%Ò%Ñ'Ô'Ð'Ý
ÐU¥d¨5¡k¤kÔ&:ÐUÐUÐUÑ
VÔ
VÐVr   )Úindentr8   úOptional[int]Úbytesc               ó`   — t          j        | |t          ¬¦  «                             d¦  «        S )z×``json.dumps`` with ``SecretStr`` values unwrapped at dump time.

    Returns bytes so call sites can pass the result inline (request content,
    ``os.write``) without binding the raw serialization to a local.
    )r8   Údefaultzutf-8)ÚjsonÚdumpsr7   Úencode)r(   r8   s     r   r   r   _   s)   € õ Œ:�g fµmÐDÑDÔD×KÒKÈGÑTÔTÐTr   ÚerrÚBaseExceptionc                ó   — d| _         | S )u›  Detach the frames chained onto ``err`` before raising from it.

    Foreign frames (json decoder, httpx transport) hold raw payloads â€”
    request bodies, response text, credentials-file contents â€” as locals.
    Dropping the traceback removes them from every renderer and programmatic
    chain-walker, while the cause's type and message (which never carry the
    payload) stay visible in renderings.
    N)Ú__traceback__)r@   s    r   r   r   h   s   € ð €CÔØ€Jr   )r(   r   r   r)   )r1   r   r   r   )r(   r   r8   r9   r   r:   )r@   rA   r   rA   )Ú
__future__r   r=   Útypingr   r   r   r   Úpydanticr   Ú__all__r6   r	   Ú	frozensetr-   r
   r   r7   r   r   © r   r   ú<module>rJ      s7  ðØ "Ð "Ð "Ð "Ð "Ð "à €€€Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,à Ð Ð Ð Ð Ð ðð ð €ð	#ð 	#ð 	#ð 	#ð 	#˜Yñ 	#ô 	#ð 	#ð  ˆiðñô €ð"ð ð ð ð@Oð Oð Oð OðWð Wð Wð Wð BFð Uð Uð Uð Uð Uð Uð
ð 
ð 
ð 
ð 
ð 
r   