Ë
    ö%9jò!  ã                   ó   — 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     úV/var/www/html/truck-me/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                 ó8   •— t         t        | �  «        || _        y ©N)Úsuperr   Ú__init__Ú_g_credential)r   r    Ú	__class__s     €r   r$   z_ExternalCredentials.__init__A   s   ø€ ÜÔ" DÑ2Ô4Ø'ˆÕ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                 ó6  •— t         t        | �  «        t        |«      r*t	        |«      5 }t        j                  |«      }ddd«       n-t        |t        «      r|}nt        dj                  |«      «      ‚j                  d«      | j                  k7  r$t        dj                  | j                  «      «      ‚	 t        j                  j                  |t         ¬«      | _        y# 1 sw Y   ŒwxY w# t        $ r}t        dj                  |«      «      ‚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.
        Nz}Invalid certificate argument: "{0}". Certificate argument must be a file path, or a dict containing the parsed file contents.ÚtypezZInvalid service account certificate. Certificate must contain a "type" field set to "{0}".©Úscopesz?Failed to initialize a certificate credential. Caused by: "{0}")r#   r.   r$   Ú_is_file_pathÚopenÚjsonÚloadÚ
isinstanceÚdictÚ
ValueErrorÚformatÚgetÚ_CREDENTIAL_TYPEr   r   Úfrom_service_account_infoÚ_scopesr%   )r   ÚcertÚ	json_fileÚ	json_dataÚerrorr&   s        €r   r$   zCertificate.__init__Q   s
  ø€ ô 	Œk˜4Ñ)Ô+Ü˜ÔÜ�d“ð 1˜yÜ ŸI™I iÓ0�	÷1ð 1ä˜œdÔ#Ø‰IäðAßAGÁÈÃóOð Oð �=‰=˜Ó  D×$9Ñ$9Ò9Üð :ß:@¹&À×AVÑAVÓ:WóYð Yð	?Ü!0×!<Ñ!<×!VÑ!VØ¤'ð "Wó "+ˆDÕ÷1ð 1ûô ò 	?Üð 0ß06±°u³ó?ð ?ûð	?ús#   ªC$Â9*C0 Ã$C-Ã0	DÃ9DÄDc                 ó.   — | j                   j                  S r"   )r%   Ú
project_idr   s    r   rD   zCertificate.project_idt   s   € à×!Ñ!×,Ñ,Ð,r   c                 ó.   — | j                   j                  S r"   )r%   Úsignerr   s    r   rF   zCertificate.signerx   s   € à×!Ñ!×(Ñ(Ð(r   c                 ó.   — | j                   j                  S r"   )r%   Úservice_account_emailr   s    r   rH   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   r<   r$   ÚpropertyrD   rF   rH   r   r+   r,   s   @r   r.   r.   L   sS   ø„ ÙCà(Ðô!?ðF ñ-ó ð-ð ñ)ó ð)ð ñ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                 ó8   •— t         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.
        N)r#   rM   r$   r%   )r   r&   s    €r   r$   zApplicationDefault.__init__‹   s   ø€ ô 	Ô  $Ñ0Ô2Ø!ˆÕ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.)rP   Ú_project_idr   s    r   rD   zApplicationDefault.project_idŸ   s   € ð 	×ÑÔØ×ÑÐr   c                 ó€   — | j                   s2t        j                  j                  t        ¬«      \  | _         | _        y y )Nr1   )r%   ÚgoogleÚauthÚdefaultr>   rR   r   s    r   rP   z#ApplicationDefault._load_credential«   s2   € Ø×!Ò!Ü39·;±;×3FÑ3FÌgÐ3FÓ3VÑ0ˆDÔ Õ 0ð "r   )
r   r   r   r   r$   r   rK   rD   rP   r+   r,   s   @r   rM   rM   ˆ   s*   ø„ Ù2ô"ò	"ð ñ	 ó ð	 öWr   rM   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        | �  «        t        |«      r*t	        |«      5 }t        j                  |«      }ddd«       n-t        |t        «      r|}nt        dj                  |«      «      ‚j                  d«      | j                  k7  r$t        dj                  | j                  «      «      ‚t        j                  j                  |t         «      | _        y# 1 sw Y   Œux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.
        Nz�Invalid refresh token argument: "{0}". Refresh token argument must be a file path, or a dict containing the parsed file contents.r0   zSInvalid refresh token configuration. JSON must contain a "type" field set to "{0}".)r#   rX   r$   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r   r   Úfrom_authorized_user_infor>   r%   )r   Úrefresh_tokenr@   rA   r&   s       €r   r$   zRefreshToken.__init__´   sÓ   ø€ ô  	Œl˜DÑ*Ô,Ü˜Ô'Ü�mÓ$ð 1¨	Ü ŸI™I iÓ0�	÷1ð 1ä˜¤tÔ,Ø%‰IäðGßGMÁvÈmÓG\ó^ð ^ð �=‰=˜Ó  D×$9Ñ$9Ò9Üð :ß:@¹&À×AVÑAVÓ:WóYð Yä(×4Ñ4×NÑNÈyÔZaÓbˆÕ÷1ð 1ús   ªC"Ã"C+c                 ó.   — | j                   j                  S r"   )r%   Ú	client_idr   s    r   r^   zRefreshToken.client_idÔ   s   € à×!Ñ!×+Ñ+Ð+r   c                 ó.   — | j                   j                  S r"   )r%   Úclient_secretr   s    r   r`   zRefreshToken.client_secretØ   ó   € à×!Ñ!×/Ñ/Ð/r   c                 ó.   — | j                   j                  S r"   )r%   r\   r   s    r   r\   zRefreshToken.refresh_tokenÜ   ra   r   c                 ó   — | j                   S rJ   r(   r   s    r   r   zRefreshToken.get_credentialà   r)   r   )r   r   r   r   r<   r$   rK   r^   r`   r\   r   r+   r,   s   @r   rX   rX   ¯   sT   ø„ ÙBà(Ðôcð@ ñ,ó ð,ð ñ0ó ð0ð ñ0ó ð0ö"r   rX   c                 óN   — 	 t        j                  | «       y# t        $ r Y yw xY w)NTF)ÚpathlibÚPathÚ	TypeError)Úpaths    r   r3   r3   è   s(   € ðÜ�‰�TÔØøÜò Ùðús   ‚ ˜	$£$)r   Úcollectionsr5   re   Úgoogle.authrT   Úgoogle.auth.credentialsr   r*   Úgoogle.auth.transportr   Úgoogle.oauth2r   r   ÚRequestr   r>   Ú
namedtupler   r   r   r.   rM   rX   r3   r   r   r   ú<module>rp      s    ðñ #Û Û Û ã Ý HÝ *Ý %Ý )ð ˆ8×ÑÓ€ò€ð )�+×(Ñ(Ð):¸^ÈXÐ<VÓW€ð÷"ñ "ô""˜4ô "ô9"�$ô 9"ôx%W˜ô %WôN6"�4ô 6"órr   