o
    Fh                     @   s\   d dl Z d dlZd dlmZmZ dedededefddZded	eeef defd
dZdS )    N)AnyDicttokenhashkwargsreturnc                    sT   t | d}d fddt D }tj| |dt jd }||kS )a	  
    Generate hexadecimal representation
    of the HMAC-SHA-256 signature of the data-check-string
    with the SHA256 hash of the bot's token used as a secret key

    :param token:
    :param hash:
    :param kwargs: all params received on auth
    :return:
    zutf-8
c                 3   s"    | ]}| d  |  V  qdS )=N ).0kr   r
   L/var/www/html/venv/lib/python3.10/site-packages/aiogram/utils/auth_widget.py	<genexpr>   s     z"check_signature.<locals>.<genexpr>)	digestmod)	hashlibsha256encodejoinsortedhmacnewdigest	hexdigest)r   r   r   secretcheck_stringhmac_stringr
   r   r   check_signature   s   r   datac                 C   s   t | fi |S )z
    Verify the authentication and the integrity
    of the data received on user's auth

    :param token: Bot's token
    :param data: all data that came on auth
    :return:
    )r   )r   r   r
   r
   r   check_integrity   s   	r   )	r   r   typingr   r   strboolr   r   r
   r
   r
   r   <module>   s
    "