§
    BP„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Z G d„ de	¦  «        Z
 G d„ d	e
¦  «        Z G d
„ de
¦  «        ZdZ G d„ de¦  «        Zd„ Z G d„ dej        ¦  «        ZdS )z;OAuth 2.0 utitilies for Google Developer Shell environment.é    N)Ú_helpers)ÚclientÚDEVSHELL_CLIENT_PORTc                   ó   — e Zd ZdZdS )ÚErrorzErrors for this module.N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    úb/root/disk_3tb/conda_envs/Huy-visual/lib/python3.11/site-packages/oauth2client/contrib/devshell.pyr   r      s   € € € € € Ø!Ð!Ø€Dr   r   c                   ó   — e Zd ZdZdS )ÚCommunicationErrorz9Errors for communication with the Developer Shell server.Nr   r   r   r   r   r   !   s   € € € € € ØCÐCÐCÐCr   r   c                   ó   — e Zd ZdZdS )ÚNoDevshellServerz6Error when no Developer Shell server can be contacted.Nr   r   r   r   r   r   %   s   € € € € € Ø@Ð@Ð@Ð@r   r   z[]c                   ó   — e Zd ZdZd„ ZdS )ÚCredentialInfoResponseaä  Credential information response from Developer Shell server.

    The credential information response from Developer Shell socket is a
    PBLite-formatted JSON array with fields encoded by their index in the
    array:

    * Index 0 - user email
    * Index 1 - default project ID. None if the project context is not known.
    * Index 2 - OAuth2 access token. None if there is no valid auth context.
    * Index 3 - Seconds until the access token expires. None if not present.
    c                 ó\  — t          j        |¦  «        }t          |t          ¦  «        st	          dt          |¦  «        z   ¦  «        ‚t          |¦  «        }|dk    r|d         nd| _        |dk    r|d         nd| _        |dk    r|d         nd| _	        |dk    r|d         nd| _
        dS )z4Initialize the response data from JSON PBLite array.zNot a list: r   Né   é   é   )ÚjsonÚloadsÚ
isinstanceÚlistÚ
ValueErrorÚstrÚlenÚ
user_emailÚ
project_idÚaccess_tokenÚ
expires_in)ÚselfÚjson_stringÚpblÚpbl_lens       r   Ú__init__zCredentialInfoResponse.__init__<   s¨   € åŒj˜Ñ%Ô%ˆÝ˜#�tÑ$Ô$ð 	8Ý˜^­c°#©h¬hÑ6Ñ7Ô7Ð7Ý�c‘(”(ˆØ$+¨a¢K K˜#˜aœ&˜&°TˆŒØ$+¨a¢K K˜#˜aœ&˜&°TˆŒØ&-°¢k k˜C œF˜F°tˆÔØ$+¨a¢K K˜#˜aœ&˜&°TˆŒˆˆr   N)r	   r
   r   r   r)   r   r   r   r   r   /   s-   € € € € € ð
ð 
ð	:ð 	:ð 	:ð 	:ð 	:r   r   c                  óê  — t          t          j        t          d¦  «        ¦  «        } | dk    rt	          ¦   «         ‚t          j        ¦   «         }|                     d| f¦  «         t          }d                     t          |¦  «        |¦  «        }| 
                    t          j        |d¬¦  «        ¦  «         |                     d¦  «                             ¦   «         }d|vrt          d¦  «        ‚|                     dd	¦  «        \  }}t          |¦  «        t          |¦  «        z
  }|dk    r5||                     |t
          j        ¦  «                             ¦   «         z  }t%          |¦  «        S )
z3Communicate with the Developer Shell server socket.r   Ú	localhostz{0}
{1}zutf-8)Úencodingé   ú
z#saw no newline in the first 6 bytesr   )ÚintÚosÚgetenvÚDEVSHELL_ENVr   ÚsocketÚconnectÚCREDENTIAL_INFO_REQUEST_JSONÚformatr    Úsendallr   Ú	_to_bytesÚrecvÚdecoder   ÚsplitÚMSG_WAITALLr   )ÚportÚsockÚdataÚmsgÚheaderÚlen_strÚjson_strÚto_reads           r   Ú	_SendRecvrE   H   s7  € õ �rŒy� qÑ)Ô)Ñ*Ô*€DØˆq‚y€yÝÑ Ô Ð åŒ=‰?Œ?€DØ‡L‚L�+˜tÐ$Ñ%Ô%Ð%å'€DØ
×
Ò
�C ™IœI tÑ
,Ô
,€CØ‡L‚L•Ô# C°'Ð:Ñ:Ô:Ñ;Ô;Ð;à�YŠY�q‰\Œ\× Ò Ñ"Ô"€FØ�6ÐÐÝ Ð!FÑGÔGÐGØŸš T¨1Ñ-Ô-Ñ€GˆXÝ�'‰lŒl�S ™]œ]Ñ*€GØ�‚{€{Ø�D—I’I˜g¥vÔ'9Ñ:Ô:×AÒAÑCÔCÑCˆå! (Ñ+Ô+Ð+r   c                   ó‚   ‡ — e Zd ZdZd	ˆ fd„	Zd„ Zed„ ¦   «         Zed„ ¦   «         Ze	d„ ¦   «         Z
ed„ ¦   «         Zˆ xZS )
ÚDevshellCredentialsaý  Credentials object for Google Developer Shell environment.

    This object will allow a Google Developer Shell session to identify its
    user to Google and other OAuth 2.0 servers that can verify assertions. It
    can be used for the purpose of accessing data stored under the user
    account.

    This credential does not require a flow to instantiate because it
    represents a two legged flow, and therefore has all of the required
    information to generate and refresh its own access tokens.
    Nc           	      óŽ   •— t          t          | ¦  «                             d d d d d d |¦  «         |                      d ¦  «         d S ©N)ÚsuperrG   r)   Ú_refresh)r%   Ú
user_agentÚ	__class__s     €r   r)   zDevshellCredentials.__init__n   sU   ø€ ÝÕ! 4Ñ(Ô(×1Ò1ØØØØØØØñ	ô 	ð 	ð 	�Š�dÑÔÐÐÐr   c                 óÜ   — t          ¦   «         | _        | j        j        | _        | j        j        }|�2t	          j        |¬¦  «        }t          j        ¦   «         |z   | _        dS d| _        dS )zXRefreshes the access token.

        Args:
            http: unused HTTP object
        N)Úseconds)	rE   Údevshell_responser#   r$   ÚdatetimeÚ	timedeltar   Ú_UTCNOWÚtoken_expiry)r%   Úhttpr$   Údeltas       r   rK   zDevshellCredentials._refreshy   sk   € õ "+¡¤ˆÔØ Ô2Ô?ˆÔØÔ+Ô6ˆ
ØÐ!ÝÔ&¨zÐ:Ñ:Ô:ˆEÝ &¤Ñ 0Ô 0°5Ñ 8ˆDÔÐÐà $ˆDÔÐÐr   c                 ó   — | j         j        S rI   )rP   r!   ©r%   s    r   r!   zDevshellCredentials.user_emailˆ   ó   € àÔ%Ô0Ð0r   c                 ó   — | j         j        S rI   )rP   r"   rX   s    r   r"   zDevshellCredentials.project_idŒ   rY   r   c                 ó    — t          d¦  «        ‚)Nz2Cannot load Developer Shell credentials from JSON.©ÚNotImplementedError)ÚclsÚ	json_datas     r   Ú	from_jsonzDevshellCredentials.from_json�   s   € å!Ø@ñBô Bð 	Br   c                 ó    — t          d¦  «        ‚)Nz-Cannot serialize Developer Shell credentials.r\   rX   s    r   Úserialization_dataz&DevshellCredentials.serialization_data•   s   € å!Ø;ñ=ô =ð 	=r   rI   )r	   r
   r   r   r)   rK   Úpropertyr!   r"   Úclassmethodr`   rb   Ú__classcell__)rM   s   @r   rG   rG   a   sÅ   ø€ € € € € ð
ð 
ð	ð 	ð 	ð 	ð 	ð 	ð%ð %ð %ð ð1ð 1ñ „Xð1ð ð1ð 1ñ „Xð1ð ðBð Bñ „[ðBð ð=ð =ñ „Xð=ð =ð =ð =ð =r   rG   )r   rQ   r   r0   r3   Úoauth2clientr   r   r2   Ú	Exceptionr   r   r   r5   Úobjectr   rE   ÚGoogleCredentialsrG   r   r   r   ú<module>rj      sa  ðð BÐ Aà €€€Ø €€€Ø 	€	€	€	Ø €€€à !Ð !Ð !Ð !Ð !Ð !Ø Ð Ð Ð Ð Ð à%€ð	ð 	ð 	ð 	ð 	ˆIñ 	ô 	ð 	ð
Dð Dð Dð Dð D˜ñ Dô Dð DðAð Að Að Að A�uñ Aô Að Að  $Ð ð:ð :ð :ð :ð :˜Vñ :ô :ð :ð2,ð ,ð ,ð27=ð 7=ð 7=ð 7=ð 7=˜&Ô2ñ 7=ô 7=ð 7=ð 7=ð 7=r   