a
    y{Jh                     @   sR   d dl Z d dlZd dlmZmZ eeeedddZeeeef ed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
   K/var/www/shaz/venv/lib/python3.9/site-packages/aiogram/utils/auth_widget.py	<genexpr>       z"check_signature.<locals>.<genexpr>)	digestmod)	hashlibsha256encodejoinsortedhmacnewdigest	hexdigest)r   r   r   secretZcheck_stringZhmac_stringr
   r   r   check_signature   s    
r   )r   datar   c                 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   