← back to Atmos Game

assets/gen/.venv/lib/python3.12/site-packages/httpx/__pycache__/_auth.cpython-312.pyc

99 lines

�

c�bjs.��F�ddlmZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZmZmZddlmZmZmZej*rdd	lmZgd
�ZGd�d�ZGd
�de�ZGd�de�ZGd�de�ZGd�de�ZGd�dej:�Zy)�)�annotationsN)�	b64encode)�parse_http_list�)�
ProtocolError)�Cookies�Request�Response)�to_bytes�to_str�unquote)�_Hash)�Auth�	BasicAuth�
DigestAuth�	NetRCAuthc�@�eZdZdZdZdZdd�Z				dd�Z				dd�Zy)	ra�
    Base class for all authentication schemes.

    To implement a custom authentication scheme, subclass `Auth` and override
    the `.auth_flow()` method.

    If the authentication scheme does I/O such as disk access or network calls, or uses
    synchronization primitives such as locks, you should override `.sync_auth_flow()`
    and/or `.async_auth_flow()` instead of `.auth_flow()` to provide specialized
    implementations that will be used by `Client` and `AsyncClient` respectively.
    Fc#�K�|��y�w)a
        Execute the authentication flow.

        To dispatch a request, `yield` it:

        ```
        yield request
        ```

        The client will `.send()` the response back into the flow generator. You can
        access it like so:

        ```
        response = yield request
        ```

        A `return` (or reaching the end of the generator) will result in the
        client returning the last response obtained from the server.

        You can dispatch as many requests as is necessary.
        N���self�requests  �b/Users/macstudio3/Projects/atmos-game/assets/gen/.venv/lib/python3.12/site-packages/httpx/_auth.py�	auth_flowzAuth.auth_flow&s
����,�
�s�c#�K�|jr|j�|j|�}t|�}	|��}|jr|j�	|j|�}�3#t$rYywxYw�w)z�
        Execute the authentication flow synchronously.

        By default, this defers to `.auth_flow()`. You should override this method
        when the authentication scheme does I/O and/or uses concurrency primitives.
        N)�requires_request_body�readr�next�requires_response_body�send�
StopIteration�rr�flow�responses    r�sync_auth_flowzAuth.sync_auth_flow>sx�����%�%��L�L�N��~�~�g�&���t�*���$�}�H��*�*��
�
��
��)�)�H�-��
��!�
��
�s*�AA>�A/�.A>�/	A;�8A>�:A;�;A>c�*K�|jr|j��d{���|j|�}t|�}	|���}|jr|j��d{���	|j|�}�<7�]7�#t$rYywxYw�w)z�
        Execute the authentication flow asynchronously.

        By default, this defers to `.auth_flow()`. You should override this method
        when the authentication scheme does I/O and/or uses concurrency primitives.
        N)r�areadrrrr r!r"s    r�async_auth_flowzAuth.async_auth_flowWs������%�%��-�-�/�!�!��~�~�g�&���t�*���$�}�H��*�*��n�n�&�&�&�
��)�)�H�-��
�
"��'��!�
��
�sF� B�B�AB�(B�)B�.B�?B�B�	B�
B�B�BN�rr	�returnz)typing.Generator[Request, Response, None])rr	r*z(typing.AsyncGenerator[Request, Response])	�__name__�
__module__�__qualname__�__doc__rrrr%r(r�rrrsD��
�"��"���0���	2��2���	1�r/rc� �eZdZdZdd�Zdd�Zy)�FunctionAuthz�
    Allows the 'auth' argument to be passed as a simple callable function,
    that takes the request, and returns a new, modified request.
    c��||_y�N��_func)r�funcs  r�__init__zFunctionAuth.__init__ws	����
r/c#�2K�|j|���y�wr3r4rs  rrzFunctionAuth.auth_flowzs�����j�j��!�!�s�N)r6z#typing.Callable[[Request], Request]r*�Noner))r+r,r-r.r7rrr/rr1r1qs���
�"r/r1c�(�eZdZdZdd�Zdd�Zdd�Zy)	rzy
    Allows the 'auth' argument to be passed as a (username, password) pair,
    and uses HTTP Basic authentication.
    c�2�|j||�|_yr3)�_build_auth_header�_auth_header�r�username�passwords   rr7zBasicAuth.__init__�s�� �3�3�H�h�G��r/c#�FK�|j|jd<|��y�w)N�
Authorization)r=�headersrs  rrzBasicAuth.auth_flow�s����+/�+<�+<�����(��
�s�!c��djt|�t|�f�}t|�j�}d|��S�N�:zBasic ��joinrr�decode�rr?r@�userpass�tokens     rr<zBasicAuth._build_auth_header��?���9�9�h�x�0�(�8�2D�E�F���(�#�*�*�,����w��r/N�r?�str | bytesr@rOr*r9r)�r?rOr@rOr*�str�r+r,r-r.r7rr<rr/rrr~s���
H�� r/rc�*�eZdZdZddd�Zdd�Zd	d�Zy)
rzT
    Use a 'netrc' file to lookup basic auth credentials based on the url host.
    Nc�8�ddl}|j|�|_y)Nr)�netrc�_netrc_info)r�filerUs   rr7zNetRCAuth.__init__�s��	� �;�;�t�,��r/c#��K�|jj|jj�}|�|ds|��y|j	|d|d��|j
d<|��y�w)N�r)r?r@rB)rV�authenticators�url�hostr<rC)rr�	auth_infos   rrzNetRCAuth.auth_flow�sl�����$�$�3�3�G�K�K�4D�4D�E�	���I�a�L��M�04�/F�/F�"�1��	�!��0G�0�G�O�O�O�,��M�s�A'A)c��djt|�t|�f�}t|�j�}d|��SrErGrJs     rr<zNetRCAuth._build_auth_header�rMr/r3)rWz
str | Noner*r9r)rPrRrr/rrr�s���-�
� r/rc	�"�eZdZUejejej
ej
ejejejejd�Zde	d<dd�Z
d
d�Z								dd�Z						dd�Z
dd�Zdd	�Zdd
�Zy)r)�MD5zMD5-SESS�SHAzSHA-SESSzSHA-256zSHA-256-SESSzSHA-512zSHA-512-SESSz*dict[str, typing.Callable[[bytes], _Hash]]�_ALGORITHM_TO_HASH_FUNCTIONc�`�t|�|_t|�|_d|_d|_y)Nr)r�	_username�	_password�_last_challenge�_nonce_countr>s   rr7zDigestAuth.__init__�s*��!�(�+���!�(�+���<@�����r/c#�8K�|jr)|j||j�|jd<|��}|jdk7sd|jvry|jj	d�D]#}|j�j
d�s�#ny|j|||�|_d|_|j||j�|jd<|jr%t|j�j|��|��y�w)NrBi�zwww-authenticatezdigest r�r)rfr<rC�status_code�get_list�lower�
startswith�_parse_challengerg�cookiesr�set_cookie_header)rrr$�auth_headers    rrzDigestAuth.auth_flow�s�������/3�/F�/F���-�-�0�G�O�O�O�,�!�=�����3�&�*<�H�DT�DT�*T�
�#�+�+�4�4�5G�H�K�� � �"�-�-�i�8��I�
�#�4�4�W�h��T������+/�+B�+B��T�)�)�,
�����(�����H�$�$�%�7�7��7�H��
�s
�BD�BDc��|jd�\}}}|j�dk(sJ�i}t|�D]3}|j�j	dd�\}	}
t|
�||	<�5	|dj
�}|dj
�}|jdd�}
d	|vr|d	j
�nd
}d|vr|dj
�nd
}t|||
||��S#t$r}d
}t||��|�d
}~wwxYw)z�
        Returns a challenge from a Digest WWW-Authenticate header.
        These take the form of:
        `Digest realm="realm@host.com",qop="auth,auth-int",nonce="abc",opaque="xyz"`
        � �digest�=r�realm�nonce�	algorithmr`�opaqueN�qop)rvrwrxryrzz(Malformed Digest WWW-Authenticate headerri)�	partitionrlr�strip�splitr
�encode�get�_DigestAuthChallenge�KeyErrorr)rrr$rq�scheme�_�fields�header_dict�field�key�valuervrwrxryrz�exc�messages                  rrnzDigestAuth._parse_challenge�s%��(�1�1�#�6����6��|�|�~��)�)�)�&(��$�V�,�E�����,�,�S�!�4�J�C��&�u�~�K���-�	C���(�/�/�1�E���(�/�/�1�E�#����U�;�I�7?�;�7N�[��*�1�1�3�TX�F�16�+�1E�+�e�$�+�+�-�4�C�'��5�I�f�RU��
���	C�@�G����9�s�B��	C�s�/A9C)�)	D�2D�Dc	�<��|j|jj��d�fd�}dj|j|j
|jf�}|jj}dj|jj�|f�}||�}d|jz}|j|j|j�}	|xjdz
c_||�}
|jj�jd�r$|dj|
|j|	f��}
|j!|j"|��}|�|
|j|g}n|
|j||	||g}|j|j
|j||dj|��|jj�d�}
|j$r|j$|
d<|rd	|
d
<||
d<|	|
d<d
|j'|
�zS)Nc�L���|�j�j�Sr3)�	hexdigestr~)�data�	hash_funcs �rrtz-DigestAuth._build_auth_header.<locals>.digests����T�?�,�,�.�5�5�7�7r/rFs%08xrz-sessri)r?rvrw�urir$rxry�authrz�nc�cnoncezDigest )r��bytesr*r�)rbrx�upperrHrdrvrer[�raw_path�methodr~rg�_get_client_noncerwrl�endswith�_resolve_qoprzry�_get_header_value)rr�	challengert�A1�path�A2�HA2�nc_valuer��HA1rz�digest_data�format_argsr�s              @rr<zDigestAuth._build_auth_header�s�����4�4�Y�5H�5H�5N�5N�5P�Q�	�	8��Y�Y����	������H�
I���{�{�#�#��
�Y�Y����-�-�/��6�
7���R�j���T�.�.�.���'�'��(9�(9�9�?�?�K�����Q����R�j�����$�$�&�/�/��8�����C����&�#A�B�C�C����	�
�
�w��?���;��	����5�K��	����6�3��L�K�����_�_��_�_���t�y�y��5�6�"�,�,�3�3�5�

�����$-�$4�$4�K��!��!(�K��� (�K���$*�K��!��4�1�1�+�>�>�>r/c� �t|�j�}||z
}|tj�j�z
}|t	j
d�z
}t
j|�j�ddj�S)N��)	rQr~�time�ctime�os�urandom�hashlib�sha1r�)r�nonce_countrw�ss    rr�zDigestAuth._get_client_nonce/sp�����#�#�%��	�U�
��	�T�Z�Z�\�
 �
 �
"�"��	�R�Z�Z��]����|�|�A��(�(�*�3�B�/�6�6�8�8r/c��d}d}d}d}t|j��D]8\}\}}|dkDr|dz
}||vr|n|}	||	j|t|��z
}�:|S)N)rxrzr�z{}="{}"z{}={}�rz, )�	enumerate�items�formatr)
r�
header_fields�NON_QUOTED_FIELDS�QUOTED_TEMPLATE�NON_QUOTED_TEMPLATE�header_value�ir�r��templates
          rr�zDigestAuth._get_header_value7s���6��#��%����!*�=�+>�+>�+@�!A��A�~��u��1�u���$��� 1�1� �(�
�

�H�O�O�E�6�%�=�A�A�L�"B��r/c��|�ytjd|�}d|vry|dgk(rtd��d|�d�}t||���)Ns, ?r�sauth-intz.Digest auth-int support is not yet implementedzUnexpected qop value "z" in digest authri)�rer}�NotImplementedErrorr)rrzr�qopsr�s     rr�zDigestAuth._resolve_qopIsV���;���x�x���$���d�?���K�=� �%�&V�W�W�*�3�'�1A�B���G�W�5�5r/NrNr))rr	r$r
rqrQr*r�)rr	r�r�r*rQ)r��intrwr�r*r�)r�zdict[str, bytes]r*rQ)rz�bytes | Nonerr	r*r�)r+r,r-r��md5r��sha256�sha512rb�__annotations__r7rrnr<r�r�r�rr/rrr�s����{�{��K�K��|�|��L�L��>�>�����>�>����	O��!K�	���>C��C�*2�C�AD�C�	�C�>.?��.?�+?�.?�	�.?�`9��$6r/rc�@�eZdZUded<ded<ded<ded<ded<y	)
r�r�rvrwrQrxr�ryrzN)r+r,r-r�rr/rr�r�Ws���L��L��N���	�r/r�)�
__future__rr�r�r�r��typing�base64r�urllib.requestr�_exceptionsr�_modelsrr	r
�_utilsrrr
�
TYPE_CHECKINGr�__all__rr1rrr�
NamedTupler�rr/r�<module>r�s���"��	�	��
��*�&�/�/�-�-�	����;��X�X�v
"�4�
"� �� �& �� �<e6��e6�P�6�,�,�r/