Ë
    Fü´jÑ  ã                  ób   — d Z ddlmZ ddlmZmZmZmZmZ ddl	m
Z
mZ ddlmZ  G d„ de«      Zy)	zProvide the Auth class.é    )Úannotations)Ú
AuthorizerÚDeviceIDAuthorizerÚImplicitAuthorizerÚUntrustedAuthenticatorÚsession)ÚInvalidImplicitAuthÚ!MissingRequiredAttributeException)ÚPRAWBasec                  ó\   — e Zd ZdZedd„«       Zdd„Zdd„Zdd„Zdddœ	 	 	 	 	 	 	 	 	 dd	„Z	y
)ÚAuthz5Auth provides an interface to Reddit's authorization.c                ó¤   — | j                   j                  €J ‚| j                   j                  j                  }|j                  |j                  dœS )at  A dictionary containing the rate limit info.

        The keys are:

        :remaining: The number of requests remaining to be made in the current rate
            limit window.
        :used: The number of requests made in the current rate limit window.

        All values are initially ``None`` as these values are set in response to issued
        requests.

        )Ú	remainingÚused)Ú_redditÚ_coreÚrate_limiterr   r   )ÚselfÚdatas     úN/root/workspace/ytshorts/venv/lib/python3.12/site-packages/praw/models/auth.pyÚlimitszAuth.limits   sG   € ð �|‰|×!Ñ!Ð-Ð-Ð-Ø�|‰|×!Ñ!×.Ñ.ˆàŸ™Ø—I‘Iñ
ð 	
ó    c                ór  — | j                   j                  €J ‚| j                   j                  j                  j                  }t	        |¬«      }|j                  |«       t        || j                   j                  j                  ¬«      }|x| j                   _	        | j                   _
        |j                  S )a7  Complete the web authorization flow and return the refresh token.

        :param code: The code obtained through the request to the redirect uri.

        :returns: The obtained refresh token, if available, otherwise ``None``.

        The session's active authorization will be updated upon success.

        )Úauthenticator©Ú
authorizerÚwindow_size)r   Ú_read_only_corer   r   r   Ú	authorizer   Úconfigr   r   Ú_authorized_coreÚrefresh_token)r   Úcoder   r   Úauthorized_sessions        r   r   zAuth.authorize)   sŽ   € ð �|‰|×+Ñ+Ð7Ð7Ð7ØŸ™×4Ñ4×?Ñ?×MÑMˆÜ¨mÔ<ˆ
Ø×Ñ˜TÔ"Ü$°
ÈÏÉ×H[ÑH[×HgÑHgÔhÐØ=OÐOˆ�‰Ô˜TŸ\™\Ô:Ø×'Ñ'Ð'r   c               óh  — | j                   j                  €J ‚| j                   j                  j                  j                  }t	        |t
        «      st        ‚t        t        ||||¬«      | j                   j                  j                  ¬«      }|x| j                   _        | j                   _        y)a  Set the active authorization to be an implicit authorization.

        :param access_token: The access_token obtained from Reddit's callback.
        :param expires_in: The number of seconds the ``access_token`` is valid for. The
            origin of this value was returned from Reddit's callback. You may need to
            subtract an offset before passing in this number to account for a delay
            between when Reddit prepared the response, and when you make this function
            call.
        :param scope: A space-delimited string of Reddit OAuth2 scope names as returned
            from Reddit's callback.

        :raises: :class:`.InvalidImplicitAuth` if :class:`.Reddit` was initialized for a
            non-installed application type.

        N)Úaccess_tokenr   Ú
expires_inÚscoper   )r   r   r   r   Ú
isinstancer   r	   r   r   r    r   r   r!   )r   r&   r'   r(   r   Úimplicit_sessions         r   ÚimplicitzAuth.implicit;   s”   € ð  �|‰|×+Ñ+Ð7Ð7Ð7ØŸ™×4Ñ4×?Ñ?×MÑMˆÜ˜-Ô)?Ô@Ü%Ð%Ü"Ü)Ø)¸ÐS]Ðejôð Ÿ™×+Ñ+×7Ñ7ô	
Ðð >NÐMˆ�‰Ô˜TŸ\™\Õ:r   c                ó  — | j                   j                  €J ‚| j                   j                  j                  }|j                  «       s(t	        |t
        t        f«      sJ ‚|j                  «        |j                  €J ‚|j                  S )z‹Return a set of scopes included in the current authorization.

        For read-only authorizations this should return ``{"*"}``.

        )	r   r   r   Úis_validr)   r   r   ÚrefreshÚscopes)r   r   s     r   r/   zAuth.scopesW   s}   € ð �|‰|×!Ñ!Ð-Ð-Ð-Ø—\‘\×'Ñ'×2Ñ2ˆ
Ø×"Ñ"Ô$ô ˜j¬:Ô7IÐ*JÔKÐKÐKØ×ÑÔ Ø× Ñ Ð,Ð,Ð,Ø× Ñ Ð r   Ú	permanentF)Údurationr+   c               óÆ  — | j                   j                  €J ‚| j                   j                  j                  €J ‚| j                   j                  j                  j                  }|j                  | j                   j
                  j                  u rd}t        |«      ‚t        |t        «      r|j                  |rdn||||¬«      S |rt        ‚|j                  |||¬«      S )a)  Return the URL used out-of-band to grant access to your application.

        :param duration: Either ``"permanent"`` or ``"temporary"`` (default:
            ``"permanent"``). ``"temporary"`` authorizations generate access tokens that
            last only 1 hour. ``"permanent"`` authorizations additionally generate a
            refresh token that expires 1 year after the last use and can be used
            indefinitely to generate new hour-long access tokens. This value is ignored
            when ``implicit=True``.
        :param implicit: For **installed** applications, this value can be set to use
            the implicit, rather than the code flow. When ``True``, the ``duration``
            argument has no effect as only temporary tokens can be retrieved.
        :param scopes: A list of OAuth scopes to request authorization for.
        :param state: A string that will be reflected in the callback to
            ``redirect_uri``. This value should be temporarily unique to the client for
            whom the URL was generated for.

        zredirect_uri must be providedÚ	temporary)r1   r+   r/   Ústate)r1   r/   r4   )r   r   Ú_authorizerÚ_authenticatorÚredirect_urir    ÚCONFIG_NOT_SETr
   r)   r   Úauthorize_urlr	   )r   r1   r+   r/   r4   r   Úmsgs          r   ÚurlzAuth.urlg   sÖ   € ð2 �|‰|×+Ñ+Ð7Ð7Ð7Ø�|‰|×+Ñ+×7Ñ7ÐCÐCÐCØŸ™×4Ñ4×@Ñ@×OÑOˆØ×%Ñ%¨¯©×)<Ñ)<×)KÑ)KÑKØ1ˆCÜ3°CÓ8Ð8Ü�mÔ%;Ô<Ø ×.Ñ.Ù(0™°hØ!ØØð	 /ó ð ñ Ü%Ð%Ø×*Ñ*°HÀVÐSXÐ*ÓYÐYr   N)Úreturnzdict[str, str | int | None])r#   Ústrr<   z
str | None)r&   r=   r'   Úintr(   r=   r<   ÚNone)r<   zset[str])
r1   r=   r+   Úboolr/   z	list[str]r4   r=   r<   r=   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úpropertyr   r   r+   r/   r;   © r   r   r   r      sl   „ Ù?àò
ó ð
ó((ó$Nó8!ð& $Øñ	(Zð ð(Zð ð	(Zð
 ð(Zð ð(Zð 
ô(Zr   r   N)rD   Ú
__future__r   Úprawcorer   r   r   r   r   Úpraw.exceptionsr	   r
   Úpraw.models.baser   r   rF   r   r   ú<module>rK      s.   ðÙ å "÷õ ÷ SÝ %ô~Zˆ8õ ~Zr   