ó
    ¢óýjm#  ã                  óˆ  • % S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKJr  SSKJr  SSKJrJrJr  SSKJr  SS	KJr  \R.                  " \5      r\R4                  " S
5      rSrS\S'    " S S\R<                  5      r " S S\S9r  " S S5      r! " S S\!5      r"SS jr#\SS j5       r$ " S S5      r%g)z 
Keyring implementation support
é    )ÚannotationsN)ÚExceptionTrap)Úonceé   )ÚcredentialsÚerrorsÚutil)Ú
properties)ÚmetadataÚpriorityz.typing.Callable[[KeyringBackend], bool] | NoneÚ_limitc                  ó8   ^ • \ rS rSrSrU 4S jrS rS rSrU =r	$ )ÚKeyringBackendMetaé   z}
Specialized subclass behavior.

Keeps a registry of all (non-abstract) types.

Wraps set_password to validate the username.
c                óf   >• [         TU ]  XU5        U R                  5         U R                  5         g ©N)ÚsuperÚ__init__Ú	_registerÚ"_validate_username_in_set_password)ÚclsÚnameÚbasesÚdictÚ	__class__s       €Ú:/usr/local/lib/python3.13/site-packages/keyring/backend.pyr   ÚKeyringBackendMeta.__init__'   s'   ø€ Ü‰Ñ˜ dÔ+Ø�‰ŒØ×.Ñ.Õ0ó    c                ó¢   • [        U S5      (       d  [        5       U l        U R                  nU R                  (       d  UR	                  U 5        g g )NÚ_classes)ÚhasattrÚsetr    Ú__abstractmethods__Úadd)r   Úclassess     r   r   ÚKeyringBackendMeta._register,   s;   € Ü�s˜J×'Ñ'Ü›5ˆCŒLØ—,‘,ˆØ×&×&Ø�K‰K˜Õð 'r   c                óh   ^• U R                   m[        R                  " T5      U4S j5       nXl         g)z=
Wrap ``set_password`` such to validate the passed username.
c                ó@   >• U R                  U5        T" XU/UQ70 UD6$ r   )Ú_validate_username)ÚselfÚsystemÚusernameÚargsÚkwargsÚorigs        €r   ÚwrapperÚFKeyringBackendMeta._validate_username_in_set_password.<locals>.wrapper9   s(   ø€ à×#Ñ# HÔ-Ù˜ hÐ@°Ò@¸Ñ@Ð@r   N)Úset_passwordÚ	functoolsÚwraps)r   r0   r/   s     @r   r   Ú5KeyringBackendMeta._validate_username_in_set_password3   s5   ø€ ð ×Ñˆä	�Š˜Ó	ô	Aó 
ð	Að #Õr   © )
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   Ú__static_attributes__Ú__classcell__)r   s   @r   r   r      s   ø† ñõ1ò
÷#ð #r   r   c                  ór  • \ rS rSrSrS r\R                  SS j5       r\	" 5       R                  r
\R                  \
S 5       5       r\    SS j5       r\R                  SS j5       rSS jr\R"                  SS	 j5       rSS
 jr\R"                  SS j5       rSS jr      SS jrSS jrSS jrSrg)ÚKeyringBackendéA   zUThe abstract base class of the keyring, every backend must implement
this interface.
c                ó$   • U R                  5         g r   )Úset_properties_from_env©r*   s    r   r   ÚKeyringBackend.__init__F   s   € Ø×$Ñ$Õ&r   c                ó   • [         e)ae  
Each backend class must supply a priority, a number (float or integer)
indicating the priority of the backend relative to all other backends.
The priority need not be static -- it may (and should) vary based
attributes of the environment in which is runs (platform, available
packages, etc.).

A higher number indicates a higher priority. The priority should raise
a RuntimeError with a message indicating the underlying cause if the
backend is not suitable for the current environment.

As a rule of thumb, a priority between zero but less than one is
suitable, but a priority of one or greater is recommended.
)ÚNotImplementedErrorrC   s    r   r   ÚKeyringBackend.priorityI   s
   € ô  "Ð!r   c                ó   • U R                     g r   )r   ©r   s    r   ÚviableÚKeyringBackend.viable^   s   € ð 	�‹r   c                óV   • [        [        R                  " S5      U R                  5      $ )z&
Return all subclasses deemed viable.
rJ   )ÚfilterÚoperatorÚ
attrgetterr    rI   s    r   Úget_viable_backendsÚ"KeyringBackend.get_viable_backendsc   s    € ô ”h×)Ò)¨(Ó3°S·\±\ÓBÐBr   c                óš   • U R                   R                  S5      u  pnUR                  SS5      nSR                  X0R                  /5      $ )zZ
The keyring name, suitable for display.

The name is derived from module and class name.
Ú.Ú_Ú )r8   Ú
rpartitionÚreplaceÚjoinr7   )r   ÚparentÚsepÚmod_names       r   r   ÚKeyringBackend.namel   sE   € ð !$§¡× 9Ñ 9¸#Ó >Ñˆ�XØ×#Ñ# C¨Ó-ˆà�x‰x˜§<¡<Ð0Ó1Ð1r   c                ól   • [        U 5      nUR                   SUR                   SUR                  S S3$ )NrS   z (priority: ÚgÚ))Útyper8   r7   r   )r*   Úkeyring_classs     r   Ú__str__ÚKeyringBackend.__str__x   s>   € Ü˜T›
ˆØ×*Ñ*Ð+¨1¨]×-CÑ-CÐ,DÀLÐQ^×QgÑQgÐhiÐPjÐjkÐlÐlr   c                ó   • g)z,Get password of the username for the serviceNr6   ©r*   Úservicer,   s      r   Úget_passwordÚKeyringBackend.get_password|   s   € ð r   c                óH   • U(       d  [         R                  " S[        SS9  gg)z#
Ensure the username is not empty.
z(Empty usernames are deprecated. See #668é   )Ú
stacklevelN)ÚwarningsÚwarnÚDeprecationWarning)r*   r,   s     r   r)   Ú!KeyringBackend._validate_username�   s!   € ö Ü�MŠMØ:Ü"Øóð r   c                ó.   • [         R                  " S5      e)znSet password for the username of the service.

If the backend cannot store passwords, raise
PasswordSetError.
Úreason)r   ÚPasswordSetError©r*   rf   r,   Úpasswords       r   r2   ÚKeyringBackend.set_password�   s   € ô ×%Ò% hÓ/Ð/r   c                ó.   • [         R                  " S5      e)zyDelete the password for the username of the service.

If the backend cannot delete passwords, raise
PasswordDeleteError.
rq   )r   ÚPasswordDeleteErrorre   s      r   Údelete_passwordÚKeyringBackend.delete_password™   s   € ô ×(Ò(¨Ó2Ð2r   c                ó^   • Ub*  U R                  X5      nUb  [        R                  " X#5      $ g)zØGets the username and password for the service.
Returns a Credential instance.

The *username* argument is optional and may be omitted by
the caller or ignored by the backend. Callers must use the
returned username.
N)rg   r   ÚSimpleCredentialrs   s       r   Úget_credentialÚKeyringBackend.get_credential¤   s4   € ð ÑØ×(Ñ(¨Ó;ˆHØÑ#Ü"×3Ò3°HÓGÐGØr   c                ó    • SS jn[        S[        U[        R                  R	                  5       5      5      nU H  u  p4[        XU5        M     g)z6For all KEYRING_PROPERTY_* env var, set that property.c                óh   • U u  pUR                  S5      u  p4nU=(       a    UR                  5       U4$ )NÚKEYRING_PROPERTY_)Ú	partitionÚlower)ÚitemÚkeyÚvalueÚprerZ   r   s         r   ÚparseÚ5KeyringBackend.set_properties_from_env.<locals>.parseº   s2   € Ø‰JˆCØ Ÿ]™]Ð+>Ó?‰NˆC�dØ×0˜DŸJ™J›L¨%Ð0Ð0r   N)rƒ   ztuple[str, str])rM   ÚmapÚosÚenvironÚitemsÚsetattr)r*   r‡   Úpropsr   r…   s        r   rB   Ú&KeyringBackend.set_properties_from_env·   s?   € ô	1ô
 *0°´c¸%ÄÇÁ×AQÑAQÓASÓ6TÓ)UˆÛ ‰KˆDÜ�D Ö&ò !r   c                óf   • [         R                   " U 5      n[        U5      R                  U5        U$ r   )ÚcopyÚvarsÚupdate)r*   r.   Úalts      r   Úwith_propertiesÚKeyringBackend.with_propertiesÃ   s&   € Ü�iŠi˜‹oˆÜˆS‹	×Ñ˜Ô Øˆ
r   r6   N)ÚreturnÚfloat)r   ztype[KeyringBackend]r—   zfilter[type[KeyringBackend]])r—   Ústr)rf   r™   r,   r™   r—   ú
str | None)r,   r™   r—   ÚNone)rf   r™   r,   r™   rt   r™   r—   r›   )rf   r™   r,   r™   r—   r›   )rf   r™   r,   rš   r—   zcredentials.Credential | None©r—   r›   )r.   ú
typing.Anyr—   r?   )r7   r8   r9   r:   r;   r   r
   Úclasspropertyr   r   ÚpassesrJ   ÚclassmethodrP   r   rb   ÚabcÚabstractmethodrg   r)   r2   rx   r|   rB   r•   r<   r6   r   r   r?   r?   A   s  † ñò'ð ×Ñó"ó ð"ñ$ ‹_×#Ñ#€Fà×ÑØñó ó ðð ðCØ!ðCà	%óCó ðCð ×Ñó	2ó ð	2ômð 	×Ñóó ðô	ð 	×Ñó0ó ð0ô3ðàðð ðð 
'ô	ô&
'÷r   r?   )Ú	metaclassc                  ó`   • \ rS rSrSr\R                  S 5       r\R                  S 5       rSr	g)ÚCrypteréÉ   z.Base class providing encryption and decryptionc                ó   • g)zEncrypt the value.Nr6   ©r*   r…   s     r   ÚencryptÚCrypter.encryptÌ   ó   € ð 	r   c                ó   • g)zDecrypt the value.Nr6   r¨   s     r   ÚdecryptÚCrypter.decryptÑ   r«   r   r6   N)
r7   r8   r9   r:   r;   r¡   r¢   r©   r­   r<   r6   r   r   r¥   r¥   É   s7   † Ù8à×Ññó ðð 	×Ññó ór   r¥   c                  ó$   • \ rS rSrSrS rS rSrg)ÚNullCrypteré×   zA crypter that does nothingc                ó   • U$ r   r6   r¨   s     r   r©   ÚNullCrypter.encryptÚ   ó   € Øˆr   c                ó   • U$ r   r6   r¨   s     r   r­   ÚNullCrypter.decryptÝ   r´   r   r6   N)r7   r8   r9   r:   r;   r©   r­   r<   r6   r   r   r°   r°   ×   s   † Ù%òõr   r°   c                 ó"  • [         R                  " SS9 HM  n  [        R                  SU R                  5        U R                  5       n[        U5      (       a	  U" 5         MM  MO     g! [         a    [        R                  SU  S35         Mx  f = f)aÍ  
Locate all setuptools entry points by the name 'keyring backends'
and initialize them.
Any third-party library may register an entry point by adding the
following to their setup.cfg::

    [options.entry_points]
    keyring.backends =
        plugin_name = mylib.mymodule:initialize_func

`plugin_name` can be anything, and is only used to display the name
of the plugin at initialization time.

`initialize_func` is optional, but will be invoked if callable.
zkeyring.backends)Úgroupz
Loading %szError initializing plugin rS   N)	r   Úentry_pointsÚlogÚdebugr   ÚloadÚcallableÚ	ExceptionÚ	exception)ÚepÚ	init_funcs     r   Ú_load_pluginsrÂ   á   sx   € ô  ×#Ò#Ð*<Ô=ˆð	>Ü�I‰I�l B§G¡GÔ,ØŸ™›	ˆIÜ˜	×"Ñ"Ù–ñ #ò	 >øô ó 	>Ü�M‰MÐ6°r°d¸!Ð<×=ð	>ús   ™AA'Á'#BÂBc                 ó†   • [        5         [        R                  5       n [        R                  " U [
        S9n[        U5      $ )zW
Return a list of all implemented keyrings that can be constructed without
parameters.
)Ú
exceptions)rÂ   r?   rP   r	   Úsuppress_exceptionsÚ	TypeErrorÚlist)Úviable_classesÚringss     r   Úget_all_keyringrÊ   û   s3   € ô „OÜ#×7Ñ7Ó9€NÜ×$Ò$ ^Ä	ÑJ€EÜ�‹;Ðr   c                  ó\   • \ rS rSrSrSr\" \" SSS9\" SSS9S	9r S       SS jjrSr	g
)ÚSchemeSelectablei  aÓ  
Allow a backend to select different "schemes" for the
username and service.

>>> backend = SchemeSelectable()
>>> backend._query('contoso', 'alice')
{'username': 'alice', 'service': 'contoso'}
>>> backend._query('contoso')
{'service': 'contoso'}
>>> backend.scheme = 'KeePassXC'
>>> backend._query('contoso', 'alice')
{'UserName': 'alice', 'Title': 'contoso'}
>>> backend._query('contoso', 'alice', foo='bar')
{'UserName': 'alice', 'Title': 'contoso', 'foo': 'bar'}
Údefaultr,   rf   )r,   rf   ÚUserNameÚTitle)rÍ   Ú	KeePassXCNc                ót   • U R                   U R                     n[        Ub  US   UUS   U0OUS   U040 UD6$ )Nr,   rf   )ÚschemesÚschemer   )r*   rf   r,   ÚbaserÓ   s        r   Ú_queryÚSchemeSelectable._query  sa   € ð —‘˜dŸk™kÑ*ˆÜð
 Ñ#ð �zÑ" HØ�yÑ! 7ñð �yÑ! 7ðñ

ð ñ

ð 
	
r   r6   r   )rf   r™   r,   rš   rÔ   r�   r—   zdict[str, str])
r7   r8   r9   r:   r;   rÓ   r   rÒ   rÕ   r<   r6   r   r   rÌ   rÌ     s[   † ñð  €FÙÙ˜j°)Ñ<Ù 
°GÑ<ñ€Gð 48ð
Øð
Ø&0ð
ØAKð
à	÷
ð 
r   rÌ   rœ   )r—   zlist[KeyringBackend])&r;   Ú
__future__r   r¡   r‘   r3   ÚloggingrN   rŠ   Útypingrl   Újaraco.contextr   Újaraco.functoolsr   Ú r   r   r	   Úcompatr
   Úcompat.py312r   Ú	getLoggerr7   rº   rO   Úby_priorityr   Ú__annotations__ÚABCMetar   r?   r¥   r°   rÂ   rÊ   rÌ   r6   r   r   Ú<module>rã      sÀ   ðòõ #ã 
Û Û Û Û Û 	Û Û å (Ý !ç 'Ñ 'Ý Ý "à×Ò˜Ó!€ð ×!Ò! *Ó-€Ø9=€Ð6Ó =ô #˜Ÿ™ô  #ôFEÐ1ò E÷Pñ ô�'ô ô>ð4 óó ð÷%
ò %
r   