a
    &ñ»j…  ã                   @  sf   d dl mZ d dlmZ d dlmZmZ ddlmZ ddl	m
Z
 dZG d	d
„ d
ƒZG dd„ deƒZdS )é    )Úannotations)Ú	b64encode)ÚAnyÚUnioné   )ÚAuthenticationErroré   )ÚRequest)ÚAuthÚ	BasicAuthc                   @  s    e Zd ZdZdddœdd„ZdS )r
   z	Base Authr	   zUnion[Request, Any])ÚrequestÚreturnc                 C  s   d S ©N© ©Úselfr   r   r   ú>E:\soccer\ml_env\Lib\site-packages\tls_requests/models/auth.pyÚ
build_auth   s    zAuth.build_authN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r
      s   r
   c                   @  sL   e Zd ZdZdddœdd„Zddœdd	„Zddœd
d„Zdddœdd„ZdS )r   zBasic AuthenticationzUnion[str, bytes]©ÚusernameÚpasswordc                 C  s   || _ || _d S r   r   )r   r   r   r   r   r   Ú__init__   s    zBasicAuth.__init__r	   )r   c                 C  s
   |   |¡S r   )Ú_build_auth_headersr   r   r   r   r      s    zBasicAuth.build_authc                 C  s8   t d |  | j¡|  | j¡g¡ƒ ¡ }d| |jd< d S )Nó   :zBasic %sÚAuthorization)r   ÚjoinÚ_encoder   r   ÚdecodeÚheaders)r   r   Z
auth_tokenr   r   r   r       s    &zBasicAuth._build_auth_headersÚbytes)Úvaluer   c                 C  s*   t |tƒr| d¡S t |tƒs&tdƒ‚|S )NÚlatin1z7`username` or `password` parameter must be str or byte.)Ú
isinstanceÚstrÚencoder#   r   )r   r$   r   r   r   r    $   s
    


zBasicAuth._encodeN)r   r   r   r   r   r   r   r    r   r   r   r   r      s
   r   N)Ú
__future__r   Úbase64r   Útypingr   r   Ú
exceptionsr   r   r	   Ú__all__r
   r   r   r   r   r   Ú<module>   s   