+
    –°³j/  ã                   óÒ   € R t ^ RIt^ RIHt ^ RIHtHt ^ RIt^RIH	t	 ^RI
HtHt ^RIHtHt RtRt ! R	 R
]4      t ! R R]RR7      tR R ltRR/R R lltR R ltR R ltR# )aA  Device Code OAuth (RFC 8628) for browser-based login, plus access token refresh.

The flow: the client requests a device code, displays a URL and a short user code, the user
authorizes in a browser, and the client polls ``POST {ENDPOINT}/oauth/token`` until a token is
issued. Access tokens may come with a refresh token, used to renew them transparently (see
``utils/_auth.py::get_token``).

This module is self-contained protocol logic: no printing, no persistence. Interactive flows
live in ``_login.py`` (human/library) and ``cli/auth.py`` (machine-readable event stream).
N)ÚCallable)Ú	TypedDictÚcast)Ú	constants)ÚDeviceCodeErrorÚOAuthErrorCode)Úget_sessionÚhf_raise_for_statusz,urn:ietf:params:oauth:grant-type:device_codeÚrefresh_tokenc                   ó,   a € ] tR t^(t o V 3R ltRtV tR# )ÚDeviceCodeInfoc                ób   <€ V ^8„  d   Qh/ S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[;R&   S[;R&   # )é   Údevice_codeÚ	user_codeÚverification_uriÚverification_uri_completeÚintervalÚ
expires_in©ÚstrÚint)ÚformatÚ__classdict__s   "€Úd/home/luca/screen-checking/.venv/lib/python3.14/site-packages/huggingface_hub/utils/_oauth_device.pyÚ__annotate__ÚDeviceCodeInfo.__annotate__(   sL   ø‡ ‚ ÙÑñ á�Nñ ñ Ññ ñ  #Ñ"ñ	 ñ
 �Mñ ñ �Oò ó    © N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__©r   s   @r   r   r   (   ó   ø‡ ‡ „ r   r   c                   ó,   a € ] tR t^1t o V 3R ltRtV tR# )ÚOAuthTokenResponsec                óJ   <€ V ^8„  d   Qh/ S[ ;R&   S[ ;R&   S[;R&   S[ ;R&   # )r   Úaccess_tokenr
   r   Ú
token_typer   )r   r   s   "€r   r   ÚOAuthTokenResponse.__annotate__1   s3   ø‡ ‚ ÙÑñ áÑñ ñ �Oñ ñ �Oò	 r   r   Nr   r'   s   @r   r*   r*   1   r(   r   r*   F)Útotalc                ó$   € V ^8„  d   QhR\         /# )r   Úreturn)r   )r   s   "r   r   r   8   s   € ÷ &ñ &œ^ñ &r   c                 óø  €  \        4       P                  \        P                   R2R\        P                  /\        P
                  R7      p \        V 4       T P                  4       pTP                  R^4       TP                  RR	4       TP                  R
4      '       g   TR,          TR
&   \        \        T4      #   \        P                   d&   p\        R\        P                   RT 24      ThRp?ii ; i)a  Request a device code from the Hub's OAuth device authorization endpoint.

The returned dict is normalized: `interval`, `expires_in` and `verification_uri_complete`
are always set (server values, or sensible defaults).

Raises:
    [`DeviceCodeError`]: If the request fails.
z/oauth/deviceÚ	client_id©ÚdataÚtimeoutz#Failed to request device code from z/oauth/device: Nr   r   i„  r   r   )r   Úpostr   ÚENDPOINTÚDEVICE_CODE_OAUTH_CLIENT_IDÚHF_HUB_DOWNLOAD_TIMEOUTr	   ÚhttpxÚ	HTTPErrorr   ÚjsonÚ
setdefaultÚgetr   r   )ÚresponseÚeÚinfos      r   Úrequest_device_coderC   8   sè   € ðsÜ“=×%Ñ%Ü×!Ñ!Ð" -Ð0Øœy×DÑDÐEÜ×5Ñ5ð &ó 
ˆô
 	˜HÔ%ð �=‰=‹?€Dð 	‡O�O�J Ô"Ø‡O�O�L #Ô&Ø�8‰8Ð/×0Ò0Ø,0Ð1CÕ,DˆÐ(Ñ)Ü” Ó%Ð%øô �?‰?ô sÜÐ CÄI×DVÑDVÐCWÐWfÐghÐfiÐjÓkÐqrÐrûðsús   ‚AB? Â?C9Ã C4Ã4C9Ú
on_pendingc                ó\   € V ^8„  d   QhR\         R\        . R3,          R,          R\        /# )r   Údevice_inforD   Nr1   )r   r   r*   )r   s   "r   r   r   T   s<   € ÷ Dwñ DwÜðDwÜ08¸¸T¸Õ0BÀTÕ0IðDwäñDwr   c          	     ó*  € V R,          p\         P                  ! 4       V R,          ,           p\         P                  ! 4       V8  Ed‘   Rp \        4       P                  \        P
                   R2R\        RV R,          R\        P                  /\        P                  R7      pVP                  R	8  d   VP                  4       pTeö   R
T9   d   \        \        T4      # TP!                  R4      ;f    MÈ;\"        P$                  8X  d    Te¯   T! 4        M¦;\"        P&                  8X  d    T^,          pM†;\"        P(                  8X  d    \+        R\"        P(                  R7      h;\"        P,                  8X  d    \+        R\"        P,                  R7      hp\+        RT RTP!                  RR4       2TR7      h\         P.                  ! T4       EK«  \+        R\"        P(                  R7      h  \        P                  \        3 d     ELKi ; i)aG  Poll the token endpoint until the user authorizes the device.

Args:
    device_info (`DeviceCodeInfo`):
        The device authorization response from [`request_device_code`].
    on_pending (`Callable`, *optional*):
        Called after each "authorization pending" response (e.g. to print a progress dot).

Returns:
    `OAuthTokenResponse`: the full token response: `access_token`, and optionally
    `refresh_token` and `expires_in`.

Raises:
    [`DeviceCodeError`]: If authorization is denied, the device code expires, or the server
        returns an unexpected OAuth error.
r   r   Nú/oauth/tokenÚ
grant_typer   r3   r4   iô  r,   Úerrorz&Device code expired. Please try again.©Ú
error_codez+Authorization was denied. Please try again.zOAuth error: ú - Úerror_descriptionÚ z0Device code expired (timeout). Please try again.)ÚtimeÚ	monotonicr   r7   r   r8   Ú_DEVICE_CODE_GRANT_TYPEr9   r:   Ústatus_coder=   r;   r<   Ú
ValueErrorr   r*   r?   r   ÚAUTHORIZATION_PENDINGÚ	SLOW_DOWNÚEXPIRED_TOKENr   ÚACCESS_DENIEDÚsleep)rF   rD   r   Údeadliner5   r@   rJ   s   &$     r   Úpoll_device_tokenr[   T   sÃ  € ð& ˜:Õ&€HÜ�~Š~Ó +¨lÕ";Õ;€HÜ
�.Š.Ó
˜XÕ
%ð ˆð	Ü"“}×)Ñ)Ü×%Ñ%Ð& lÐ3à Ô"9Ø! ;¨}Õ#=Ø¤×!FÑ!Fðô
 "×9Ñ9ð *ó ˆHð ×#Ñ# cÔ)Ø—}‘}“�ð ÒØ Ô%ÜÔ.°Ó5Ð5à—(‘(˜7Ó#ÛÙØ9”^×9Ö9Ù!Ò-Ù"�Ø-”^×-Ö-Ù •M‘HØ1”^×1Ö1Ý)Ø@Ì^×MiÑMiôð ð 2”^×1Ö1Ý)ØEÔR`×RnÑRnôð ð Ü)Ø'¨ w¨c°$·(±(Ð;NÐPRÓ2SÐ1TÐUÐbgôð ô 	�
Š
�8×ä
ÐLÔYg×YuÑYuÔ
vÐvøô= —‘¤Ð,ô 	Úð	ús   ÁA;G3 Ç3HÈHc                ó0   € V ^8„  d   QhR\         R\        /# )r   r
   r1   )r   r*   )r   s   "r   r   r   ›   s   € ÷  ñ  ¬ð  Ô0Bñ  r   c           	     óÖ  €  \        4       P                  \        P                   R2R\        RV R\        P
                  /\        P                  R7      p\        T4      pRT9   d   \        \        T4      # TP                  R	4      p\        RT;'       g    TP                   R
TP                  RR4       2TR7      h  \        P                   d   p\        RT 24      ThRp?ii ; i)ax  Exchange a refresh token for a new access token.

Returns:
    `OAuthTokenResponse`: the full token response: `access_token`, and optionally a rotated
    `refresh_token` and `expires_in`.

Raises:
    [`DeviceCodeError`]: If the server rejects the refresh (`error_code="invalid_grant"` when
        the refresh token is expired or revoked) or returns an unexpected response.
rH   rI   r
   r3   r4   z Failed to refresh access token: Nr,   rJ   rM   rN   rO   rK   )r   r7   r   r8   Ú_REFRESH_TOKEN_GRANT_TYPEr9   r:   r;   r<   r   Ú_parse_token_responser   r*   r?   rS   )r
   r@   rA   r5   rJ   s   &    r   Úrefresh_access_tokenr`   ›   sð   € ðMÜ“=×%Ñ%Ü×!Ñ!Ð" ,Ð/àÔ7Ø ØœY×BÑBðô ×5Ñ5ð &ó 

ˆô ! Ó*€DØ˜ÔÜÔ&¨Ó-Ð-Ø�H‰H�WÓ€EÜ
Ø
*¨5×+HÐ+H°H×4HÑ4HÐ*IÈÈTÏXÉXÐViÐkmÓMnÐLoÐpØôð øô �?‰?ô MÜÐ @ÀÀÐDÓEÈ1ÐLûðMús   ‚AB? Â?C(ÃC#Ã#C(c                óD   € V ^8„  d   QhR\         P                  R\        /# )r   r@   r1   )r;   ÚResponseÚdict)r   s   "r   r   r   ¾   s   € ÷ ñ ¤E§N¡Nð ´tñ r   c           
      óÆ   €  V P                  4       #   \         dD   p\        R \        P                   RT P
                   RT P                  R,           24      ThRp?ii ; i)zFailed to parse response from z/oauth/token (status z): :Niô  NN)r=   rT   r   r   r8   rS   Útext)r@   rA   s   & r   r_   r_   ¾   sk   € ðØ�}‰}‹ÐøÜô ÜØ,¬Y×-?Ñ-?Ð,@ð AØ×+Ñ+Ð,¨C°·±¸dÕ0CÐ/DðFó
ð ð	ûðús   ‚ ’A �>AÁA )Ú__doc__rP   Úcollections.abcr   Útypingr   r   r;   rO   r   Úerrorsr   r   Ú_httpr   r	   rR   r^   r   r*   rC   r[   r`   r_   r   r   r   Ú<module>rk      sl   ðñ	ó Ý $ß "ã å ß 4ß 3ð IÐ Ø+Ð ô�Yô ô˜¨%õ õ&ð8DwØLP÷DwõN ÷Fr   