+
    iHàj  ã                  óî   € R t ^ RIHt ^ RIt^ RIt^ RIHtHtHt ]	! 0 Rm4      t
]	! 0 Rm4      t]	! 0 Rm4      tRt]P                  ! R4      tR R ltRR R lltR	 R
 ltR R ltR R ltRR R lltR# )a  Credential-pool disk-boundary sanitization: strip raw secrets from *borrowed*
pool entries before they reach ``auth.json``. Deliberately free of
``hermes_cli.auth`` imports so the pool model and the auth-store write boundary
share one policy without import cycles.)ÚannotationsN)ÚAnyÚDictÚMappingz(?<=[a-z0-9])(?=[A-Z])c               ó    € V ^8„  d   QhRRRR/# )é   Úkeyr   ÚreturnÚstr© )Úformats   "ÚA/home/ubuntu/.hermes/hermes-agent/agent/credential_persistence.pyÚ__annotate__r   3   s   € ÷ ;ñ ;˜ð ; ñ ;ó    c                óÐ   € \         P                  R \        T ;'       g    R4      P                  4       4      pVP	                  4       P                  RR 4      P                  RR 4      # )Ú_Ú Ú-Ú.)Ú_CAMEL_CASE_BOUNDARYÚsubr
   ÚstripÚlowerÚreplace)r   Úraws   & r   Ú_normalize_keyr   3   sM   € Ü
×
"Ñ
" 3¬¨C¯I¨I°2«×(<Ñ(<Ó(>Ó
?€CØ�9‰9‹;×Ñ˜s CÓ(×0Ñ0°°cÓ:Ð:r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úsourcer   Úprovider_idr	   Úboolr   )r   s   "r   r   r   8   s&   € ÷ Yñ Y¨#ð Y¸Cð YÈ4ñ Yr   c                ó*  € \        T ;'       g    R4      P                  4       P                  4       pV'       d   VR8X  g   VP                  R4      '       d   R# \        T;'       g    R4      P                  4       P                  4       pW23\        9  # )zGReturn True when ``source`` points at a borrowed/reference-only secret.r   Úmanualzmanual:F)r
   r   r   Ú
startswithÚ_PERSISTABLE_PROVIDER_SOURCES)r   r   Únormalized_sourceÚnormalized_providers   &&  r   Úis_borrowed_credential_sourcer&   8   sy   € ä˜FŸL˜L bÓ)×/Ñ/Ó1×7Ñ7Ó9ÐßÐ 1°XÔ =ÐAR×A]ÑA]Ð^g×AhÒAhÙÜ˜k×/Ð/¨RÓ0×6Ñ6Ó8×>Ñ>Ó@ÐØÐ3Ô;XÑXÐXr   c               ó    € V ^8„  d   QhRRRR/# )r   r   r   r	   r   r   )r   s   "r   r   r   A   s   € ÷ [ñ [ ð [¨ñ [r   c                óŽ   € \        V 4      pV'       d   V\        9   d   R # V\        9   ;'       g    VP                  \        4      # )F)r   Ú_SAFE_SECRETISH_METADATA_KEYSÚ_SECRET_VALUE_KEYSÚendswithÚ_SECRET_VALUE_SUFFIXES)r   Ú
normalizeds   & r   Ú_is_secret_payload_keyr.   A   s:   € Ü Ó$€Jß˜Ô'DÔDÙØÔ+Ñ+×ZÐZ¨z×/BÑ/BÔCYÓ/ZÐZr   c               ó    € V ^8„  d   QhRRRR/# )r   Úvaluer   r	   ú
str | Noner   )r   s   "r   r   r   H   s   € ÷ 
#ñ 
# Cð 
#¨Jñ 
#r   c                óº   € V f   RM
\        V 4      pV'       g   R# \        P                  ! VP                  RRR7      4      P	                  4       pRVR,           2# )zÜNon-reversible ``sha256:<16 hex>`` fingerprint of one secret value.

Callers comparing a live secret against the ``secret_fingerprint`` left on
a sanitized (borrowed) pool row need exactly the digest this module writes.
Nr   zutf-8Úsurrogatepass)Úerrorsúsha256::Né   N)r
   ÚhashlibÚsha256ÚencodeÚ	hexdigest)r0   ÚtextÚdigests   &  r   Úfingerprint_secret_valuer=   H   sN   € ð ’‰2¤C¨£J€DßÙÜ�^Š^˜DŸK™K¨¸˜KÓHÓI×SÑSÓU€FØ�V˜C•[�MÐ"Ð"r   c               ó    € V ^8„  d   QhRRRR/# )r   ÚpayloadúMapping[str, Any]r	   r1   r   )r   s   "r   r   r   U   s   € ÷ ñ Ð,=ð À*ñ r   c                ó˜  € RpV Uu. uF  q P                  V4      NK  	  ppY0P                  4        UUu. uF  w  r$\        V4      '       g   K  VNK  	  upp,          pV F  p\        V4      pV'       g   K  Vu # 	  V P                  R4      p\	        V\
        4      '       d   VP                  R4      '       d   V# R# u upi u uppi )Ú	agent_keyÚsecret_fingerprintr5   N)rB   Úaccess_tokenÚrefresh_tokenÚapi_keyÚtokenÚsecret)ÚgetÚitemsr.   r=   Ú
isinstancer
   r"   )r?   Ú	preferredÚkÚ
candidatesÚvr0   ÚfingerprintÚexistings   &       r   Ú_credential_secret_fingerprintrR   U   s§   € Ø\€IÙ*3Ó4©) Q—+‘+˜a–.©)€JÐ4Ø§¡¤ÔN¡™˜Ô4JÈ1×4M—1�1¡ÒNÕN€JÛˆÜ.¨uÓ5ˆß‰;ØÒñ ð �{‰{Ð/Ó0€HÜ�(œC× Ò  X×%8Ñ%8¸×%CÒ%CØˆÙùò 5ùÛNs   ‡CµCÁCc               ó$   € V ^8„  d   QhRRRRRR/# )r   r?   r@   r   r   r	   zdict[str, Any]r   )r   s   "r   r   r   c   s&   € ÷ ñ Øðàðð ñr   c                ó  € \        V 4      p\        VP                  R4      V4      '       g   V# \        V4      pVP	                  4        UUu/ uF  w  rE\        V4      '       d   K  WEbK  	  pppV'       d   W6R&   V# u uppi )zâReturn a disk-safe credential-pool payload.

Owned sources pass through unchanged.  Borrowed sources keep labels,
source refs, status/cooldown metadata, counters and a fingerprint, but
every raw secret value field is removed.
r   rC   )Údictr&   rI   rR   rJ   r.   )r?   r   ÚresultrP   rM   rO   Ú	sanitizeds   &&     r   Ú$sanitize_borrowed_credential_payloadrX   c   sr   € ô �'‹]€FÜ(¨¯©°HÓ)=¸{×KÒKØˆÜ0°Ó8€KØ"(§,¡,¤.ÔR¡.™$˜!Ô8NÈq×8Q”�’¡.€IÑRßØ*5Ð&Ñ'ØÐùó Ss   ÁA>Á'A>>   ©z	xai-oauthÚdevice_code©zopenai-codexrZ   ©zminimax-oauthÚoauth©ÚnousrZ   ©Ú	anthropicÚhermes_pkce>   ÚscopeÚ	client_idÚ
expires_atÚ
expires_inÚ
token_typeÚlast_statusÚagent_key_idÚlast_refreshÚexpires_at_msÚsecret_sourceÚlast_status_atÚlast_error_codeÚagent_key_reusedÚlast_error_reasonÚlast_error_messagerC   Úlast_error_reset_atÚagent_key_expires_atÚagent_key_expires_inÚagent_key_obtained_at>   rG   ÚapikeyrH   ÚtokensrF   Úid_tokenÚpasswordrB   Ú	api_tokenÚ
auth_tokenÚ
credentialÚ
secret_keyÚcredentialsÚoauth_tokenÚprivate_keyrD   Úbearer_tokenÚauthorizationÚclient_secretrE   Úsession_token)Ú_api_keyÚ
_api_tokenÚ_access_tokenÚ_auth_tokenÚ_refresh_tokenÚ_bearer_tokenÚ_client_secretÚ	_id_tokenÚ_oauth_tokenÚ_private_keyÚ_session_tokenÚ_secret_keyÚ	_passwordÚ_secretÚ_tokenÚ_key)N)Ú__doc__Ú
__future__r   r7   ÚreÚtypingr   r   r   Ú	frozensetr#   r)   r*   r,   Úcompiler   r   r&   r.   r=   rR   rX   r   r   r   Ú<module>r›      s�   ðñ+õ
 #ã Û 	ß %Ñ %ñ !*ò +ó !Ð ñ !*ò +ó !Ð ñ ò  ó Ð ðÐ ð —z’zÐ";Ó<Ð õ;÷
Yõ[õ
#õ÷ñ r   