Ë
    ¹ÿj—!  ã                   ó   — d Z ddlZddlZddlZddlZddlmZ ddl	m
Z
 ddlmZ ddlmZ  e
j                  «       Zg d¢Z ej"                  dd	d
g«      Z	  G d„ d«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Zd„ Zy)zFirebase credentials module.é    N)ÚCredentials)Úrequests)Úcredentials)Úservice_account)z.https://www.googleapis.com/auth/cloud-platformz)https://www.googleapis.com/auth/datastorez5https://www.googleapis.com/auth/devstorage.read_writez(https://www.googleapis.com/auth/firebasez/https://www.googleapis.com/auth/identitytoolkitz.https://www.googleapis.com/auth/userinfo.emailÚAccessTokenInfoÚaccess_tokenÚexpiryc                   ó   — e Zd ZdZd„ Zd„ Zy)ÚBasez>Provides OAuth2 access tokens for accessing Firebase services.c                 óŒ   — | j                  «       }|j                  t        «       t        |j                  |j
                  «      S )z©Fetches a Google OAuth2 access token using this credential instance.

        Returns:
          AccessTokenInfo: An access token obtained using the credential.
        )Úget_credentialÚrefreshÚ_requestr   Útokenr	   )ÚselfÚgoogle_creds     úT/root/telegram-saas/.venv/lib/python3.12/site-packages/firebase_admin/credentials.pyÚget_access_tokenzBase.get_access_token0   s9   € ð ×)Ñ)Ó+ˆØ×ÑœHÔ%Ü˜{×0Ñ0°+×2DÑ2DÓEÐEó    c                 ó   — t         ‚)z?Returns the Google credential instance used for authentication.)ÚNotImplementedError©r   s    r   r   zBase.get_credential:   s   € ä!Ð!r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   © r   r   r   r   -   s   „ ÙHòFó"r   r   c                   ó.   ‡ — e Zd ZdZdefˆ fd„Zd„ Zˆ xZS )Ú_ExternalCredentialszLA wrapper for google.auth.credentials.Credentials typed credential instancesÚ
credentialc                 ó0   •— t         ‰| �  «        || _        y ©N©ÚsuperÚ__init__Ú_g_credential)r   r    Ú	__class__s     €r   r%   z_ExternalCredentials.__init__A   s   ø€ Ü‰ÑÔØ'ˆÕr   c                 ó   — | j                   S )zŒReturns the underlying Google Credential

        Returns:
          google.auth.credentials.Credentials: A Google Auth credential instance.©r&   r   s    r   r   z#_ExternalCredentials.get_credentialE   ó   € ð
 ×!Ñ!Ð!r   )r   r   r   r   ÚGoogleAuthCredentialsr%   r   Ú__classcell__©r'   s   @r   r   r   >   s   ø„ ÙVð(Ð#8õ (ö"r   r   c                   ó\   ‡ — e Zd ZdZdZˆ fd„Zed„ «       Zed„ «       Zed„ «       Z	d„ Z
ˆ xZS )ÚCertificatez9A credential initialized from a JSON certificate keyfile.r   c                 óò  •— t         ‰| �  «        t        |«      r,t        |d¬«      5 }t	        j
                  |«      }ddd«       n"t        |t        «      r|}nt        d|› d�«      ‚j                  d«      | j                  k7  rt        d| j                  › d�«      ‚	 t        j                  j                  |t        ¬	«      | _        y# 1 sw Y   ŒlxY w# t        $ r}t        d
|› d�«      |‚d}~ww xY w)a]  Initializes a credential from a Google service account certificate.

        Service account certificates can be downloaded as JSON files from the Firebase console.
        To instantiate a credential from a certificate file, either specify the file path or a
        dict representing the parsed contents of the file.

        Args:
          cert: Path to a certificate file or a dict representing the contents of a certificate.

        Raises:
          IOError: If the specified certificate file doesn't exist or cannot be read.
          ValueError: If the specified certificate is invalid.
        úutf-8©ÚencodingNzInvalid certificate argument: "z[". Certificate argument must be a file path, or a dict containing the parsed file contents.ÚtypezUInvalid service account certificate. Certificate must contain a "type" field set to "ú".©Úscopesz;Failed to initialize a certificate credential. Caused by: "ú")r$   r%   Ú_is_file_pathÚopenÚjsonÚloadÚ
isinstanceÚdictÚ
ValueErrorÚgetÚ_CREDENTIAL_TYPEr   r   Úfrom_service_account_infoÚ_scopesr&   )r   ÚcertÚ	json_fileÚ	json_dataÚerrorr'   s        €r   r%   zCertificate.__init__Q   s  ø€ ô 	‰ÑÔÜ˜ÔÜ�d WÔ-ð 1°Ü ŸI™I iÓ0�	÷1ð 1ä˜œdÔ#Ø‰IäØ1°$°ð 8Gð GóHð Hð �=‰=˜Ó  D×$9Ñ$9Ò9Üð(Ø(,×(=Ñ(=Ð'>¸bðBóCð Cð	cÜ!0×!<Ñ!<×!VÑ!VØ¤'ð "Wó "+ˆDÕ÷1ð 1ûô  ò 	cÜØMÈeÈWÐTUÐVóXØ]bðcûð	cús#   ¨CÂ!*C ÃCÃ	C6Ã!C1Ã1C6c                 ó.   — | j                   j                  S r"   )r&   Ú
project_idr   s    r   rI   zCertificate.project_idu   s   € à×!Ñ!×,Ñ,Ð,r   c                 ó.   — | j                   j                  S r"   )r&   Úsignerr   s    r   rK   zCertificate.signery   s   € à×!Ñ!×(Ñ(Ð(r   c                 ó.   — | j                   j                  S r"   )r&   Úservice_account_emailr   s    r   rM   z!Certificate.service_account_email}   s   € à×!Ñ!×7Ñ7Ð7r   c                 ó   — | j                   S ©z�Returns the underlying Google credential.

        Returns:
          google.auth.credentials.Credentials: A Google Auth credential instance.r)   r   s    r   r   zCertificate.get_credential�   r*   r   )r   r   r   r   rA   r%   ÚpropertyrI   rK   rM   r   r,   r-   s   @r   r/   r/   L   sT   ø„ ÙCà(Ðô"cðH ñ-ó ð-ð ñ)ó ð)ð ñ8ó ð8ö"r   r/   c                   ó>   ‡ — e Zd ZdZˆ fd„Zd„ Zed„ «       Zd„ Zˆ xZ	S )ÚApplicationDefaultz(A Google Application Default credential.c                 ó0   •— t         ‰| �  «        d| _        y)zæCreates an instance that will use Application Default credentials.

        The credentials will be lazily initialized when get_credential() or
        project_id() is called. See those methods for possible errors raised.
        Nr#   )r   r'   s    €r   r%   zApplicationDefault.__init__Œ   s   ø€ ô 	‰ÑÔØ!ˆÕr   c                 ó:   — | j                  «        | j                  S )a:  Returns the underlying Google credential.

        Raises:
          google.auth.exceptions.DefaultCredentialsError: If Application Default
              credentials cannot be initialized in the current environment.
        Returns:
          google.auth.credentials.Credentials: A Google Auth credential instance.)Ú_load_credentialr&   r   s    r   r   z!ApplicationDefault.get_credential•   s   € ð 	×ÑÔØ×!Ñ!Ð!r   c                 ó:   — | j                  «        | j                  S )a  Returns the project_id from the underlying Google credential.

        Raises:
          google.auth.exceptions.DefaultCredentialsError: If Application Default
              credentials cannot be initialized in the current environment.
        Returns:
          str: The project id.)rU   Ú_project_idr   s    r   rI   zApplicationDefault.project_id    s   € ð 	×ÑÔØ×ÑÐr   c                 ó€   — | j                   s2t        j                  j                  t        ¬«      \  | _         | _        y y )Nr6   )r&   ÚgoogleÚauthÚdefaultrC   rW   r   s    r   rU   z#ApplicationDefault._load_credential¬   s2   € Ø×!Ò!Ü39·;±;×3FÑ3FÌgÐ3FÓ3VÑ0ˆDÔ Õ 0ð "r   )
r   r   r   r   r%   r   rP   rI   rU   r,   r-   s   @r   rR   rR   ‰   s*   ø„ Ù2ô"ò	"ð ñ	 ó ð	 öWr   rR   c                   ó\   ‡ — e Zd ZdZdZˆ fd„Zed„ «       Zed„ «       Zed„ «       Z	d„ Z
ˆ xZS )ÚRefreshTokenz8A credential initialized from an existing refresh token.Úauthorized_userc                 ó¬  •— t         ‰| �  «        t        |«      r,t        |d¬«      5 }t	        j
                  |«      }ddd«       n"t        |t        «      r|}nt        d|› d�«      ‚j                  d«      | j                  k7  rt        d| j                  › d�«      ‚t        j                  j                  |t        «      | _        y# 1 sw Y   ŒjxY w)	a³  Initializes a credential from a refresh token JSON file.

        The JSON must consist of client_id, client_secret and refresh_token fields. Refresh
        token files are typically created and managed by the gcloud SDK. To instantiate
        a credential from a refresh token file, either specify the file path or a dict
        representing the parsed contents of the file.

        Args:
          refresh_token: Path to a refresh token file or a dict representing the contents of a
              refresh token file.

        Raises:
          IOError: If the specified file doesn't exist or cannot be read.
          ValueError: If the refresh token configuration is invalid.
        r1   r2   Nz!Invalid refresh token argument: "z]". Refresh token argument must be a file path, or a dict containing the parsed file contents.r4   zNInvalid refresh token configuration. JSON must contain a "type" field set to "r5   )r$   r%   r9   r:   r;   r<   r=   r>   r?   r@   rA   r   r   Úfrom_authorized_user_inforC   r&   )r   Úrefresh_tokenrE   rF   r'   s       €r   r%   zRefreshToken.__init__µ   sÝ   ø€ ô  	‰ÑÔÜ˜Ô'Ü�m¨gÔ6ð 1¸)Ü ŸI™I iÓ0�	÷1ð 1ä˜¤tÔ,Ø%‰IäØ3°M°?ð CQð QóRð Rð �=‰=˜Ó  D×$9Ñ$9Ò9Üð(Ø(,×(=Ñ(=Ð'>¸bðBóCð Cô )×4Ñ4×NÑNÈyÔZaÓbˆÕ÷1ð 1ús   ¨C
Ã
Cc                 ó.   — | j                   j                  S r"   )r&   Ú	client_idr   s    r   rc   zRefreshToken.client_idÖ   s   € à×!Ñ!×+Ñ+Ð+r   c                 ó.   — | j                   j                  S r"   )r&   Úclient_secretr   s    r   re   zRefreshToken.client_secretÚ   ó   € à×!Ñ!×/Ñ/Ð/r   c                 ó.   — | j                   j                  S r"   )r&   ra   r   s    r   ra   zRefreshToken.refresh_tokenÞ   rf   r   c                 ó   — | j                   S rO   r)   r   s    r   r   zRefreshToken.get_credentialâ   r*   r   )r   r   r   r   rA   r%   rP   rc   re   ra   r   r,   r-   s   @r   r]   r]   °   sT   ø„ ÙBà(ÐôcðB ñ,ó ð,ð ñ0ó ð0ð ñ0ó ð0ö"r   r]   c                 óN   — 	 t        j                  | «       y# t        $ r Y yw xY w)NTF)ÚpathlibÚPathÚ	TypeError)Úpaths    r   r9   r9   ê   s(   € ðÜ�‰�TÔØøÜò Ùðús   ‚ ˜	$£$)r   Úcollectionsr;   rj   Úgoogle.authrY   Úgoogle.auth.credentialsr   r+   Úgoogle.auth.transportr   Úgoogle.oauth2r   r   ÚRequestr   rC   Ú
namedtupler   r   r   r/   rR   r]   r9   r   r   r   ú<module>ru      s    ðñ #Û Û Û ã Ý HÝ *Ý %Ý )ð ˆ8×ÑÓ€ò€ð )�+×(Ñ(Ð):¸^ÈXÐ<VÓW€ð÷"ñ "ô""˜4ô "ô:"�$ô :"ôz%W˜ô %WôN7"�4ô 7"ótr   