§
    €î§i
  ã                  ó*   — d Z ddlmZ dd„Z	 ddd„ZdS )zš
Authentication utilities for CalDAV clients.

This module contains shared authentication logic used by both
DAVClient (sync) and AsyncDAVClient (async).
é    )ÚannotationsÚheaderÚstrÚreturnúset[str]c                ód   — d„ |                       ¦   «                              d¦  «        D ¦   «         S )a/  
    Extract authentication types from WWW-Authenticate header.

    Parses the WWW-Authenticate header value and extracts the
    authentication scheme names (e.g., "basic", "digest", "bearer").

    Args:
        header: WWW-Authenticate header value from server response.

    Returns:
        Set of lowercase auth type strings.

    Example:
        >>> extract_auth_types('Basic realm="test", Digest realm="test"')
        {'basic', 'digest'}

    Reference:
        https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/WWW-Authenticate#syntax
    c                óB   — h | ]}|                      ¦   «         d          ’ŒS )r   )Úsplit)Ú.0Úhs     úJ/root/projects/butler/venv/lib/python3.11/site-packages/caldav/lib/auth.pyú	<setcomp>z%extract_auth_types.<locals>.<setcomp>   s$   € Ð<Ð<Ð<˜QˆAGŠG‰IŒIaŒLÐ<Ð<Ð<ó    ú,)Úlowerr
   )r   s    r   Úextract_auth_typesr      s.   € ð( =Ð< &§,¢,¡.¤.×"6Ò"6°sÑ";Ô";Ð<Ñ<Ô<Ð<r   TÚ
auth_typesúset[str] | list[str]Úhas_usernameÚboolÚhas_passwordÚprefer_digestú
str | Nonec                ó„   — t          | t          ¦  «        st          | ¦  «        n| }|r|rd|v rdS d|v rdS n|rd|v rdS dS )aH  
    Select the best authentication type from available options.

    Args:
        auth_types: Available authentication types from server.
        has_username: Whether a username is configured.
        has_password: Whether a password is configured.
        prefer_digest: Whether to prefer Digest over Basic auth.

    Returns:
        Selected auth type string, or None if no suitable type found.

    Selection logic:
        - If username is set: prefer Digest (more secure) or Basic
        - If only password is set: use Bearer token auth
        - Otherwise: return None
    ÚdigestÚbasicÚbearerN)Ú
isinstanceÚset)r   r   r   r   Úauth_types_sets        r   Úselect_auth_typer!   "   ss   € õ. -7°zÅ3Ñ,GÔ,GÐW•S˜‘_”__ÈZ€Nàð Øð 	˜X¨Ð7Ð7Ø8ØnÐ$Ð$Ø7ð %à	ð à~Ð%Ð%Ø8àˆ4r   N)r   r   r   r   )T)
r   r   r   r   r   r   r   r   r   r   )Ú__doc__Ú
__future__r   r   r!   © r   r   ú<module>r%      s_   ððð ð #Ð "Ð "Ð "Ð "Ð "ð=ð =ð =ð =ð6 ð	#ð #ð #ð #ð #ð #ð #r   