ó
    ùŠÂjŠ  ã                   óf   • S SK r S SKrS SKrS SKrS SKJrJrJr  SSKJ	r	  SSK
Jr   " S S\5      rg)é    N)ÚAnyÚOptionalÚUnioné   )Úutils)ÚOTPc                   ó0  ^ • \ rS rSrSr     SS\S\S\S\\   S\\   S	\S
S4U 4S jjjr	SS\
\\R                  4   S\S
\4S jjrS
\4S jrSS\S\\R                     S\S
\4S jjrSS\\   S\\   S
\4S jjrS\R                  S
\4S jrSrU =r$ )ÚTOTPé   z&
Handler for time-based OTP counters.
NÚsÚdigitsÚdigestÚnameÚissuerÚintervalÚreturnc                 ó¶   >• Uc  [         R                  nO/U[         R                  [         R                  4;   a  [	        S5      eX`l        [        TU ]  XX4US9  g)aP  
:param s: secret in base32 format
:param digits: number of integers in the OTP. Some apps expect this to be 6 digits, others support more.
:param digest: digest function to use in the HMAC (expected to be SHA1)
:param name: account name
:param issuer: issuer
:param interval: the time interval in seconds for OTP. This defaults to 30.
NzUselected digest function must generate digest size greater than or equals to 18 bytes)r   r   r   r   r   )ÚhashlibÚsha1Úmd5Ú	shake_128Ú
ValueErrorr   ÚsuperÚ__init__)Úselfr   r   r   r   r   r   Ú	__class__s          €Ú@/var/www/website/venv/lib/python3.13/site-packages/pyotp/totp.pyr   ÚTOTP.__init__   sO   ø€ ð" ‰>Ü—\‘\‰FØœŸ™¤W×%6Ñ%6Ð7Ó7ÜÐtÓuÐuà ŒÜ‰Ñ˜1°FÈfÐÒUó    Úfor_timeÚcounter_offsetc                 óÖ   • [        U[        R                  5      (       d(  [        R                  R                  [        U5      5      nU R	                  U R                  U5      U-   5      $ )a½  
Accepts either a Unix timestamp integer or a datetime object.

To get the time until the next timecode change (seconds until the current OTP expires), use this instead:

.. code:: python

    totp = pyotp.TOTP(...)
    time_remaining = totp.interval - datetime.datetime.now().timestamp() % totp.interval

:param for_time: the time to generate an OTP for
:param counter_offset: the amount of ticks to add to the time counter
:returns: OTP value
)Ú
isinstanceÚdatetimeÚfromtimestampÚintÚgenerate_otpÚtimecode)r   r    r!   s      r   ÚatÚTOTP.at)   sP   € ô ˜(¤H×$5Ñ$5×6Ñ6Ü×(Ñ(×6Ñ6´s¸8³}ÓEˆHØ× Ñ  §¡¨xÓ!8¸>Ñ!IÓJÐJr   c                 óz   • U R                  U R                  [        R                  R                  5       5      5      $ )z4
Generate the current time OTP

:returns: OTP value
)r'   r(   r$   Únow)r   s    r   r,   ÚTOTP.now<   s-   € ð × Ñ  §¡¬x×/@Ñ/@×/DÑ/DÓ/FÓ!GÓHÐHr   ÚotpÚvalid_windowc           
      óp  • Uc  [         R                   R                  5       nU(       aW  [        U* US-   5       HB  n[        R                  " [        U5      [        U R                  X$5      5      5      (       d  MB    g   g[        R                  " [        U5      [        U R                  U5      5      5      $ )a8  
Verifies the OTP passed in against the current time OTP.

:param otp: the OTP to check against
:param for_time: Time to check OTP at (defaults to now)
:param valid_window: extends the validity to this many counter ticks before and after the current one
:returns: True if verification succeeded, False otherwise
r   TF)r$   r,   Úranger   Ústrings_equalÚstrr)   )r   r.   r    r/   Úis        r   ÚverifyÚTOTP.verifyD   s‹   € ð ÑÜ×(Ñ(×,Ñ,Ó.ˆHæÜ˜L˜=¨,¸Ñ*:Ö;�Ü×&Ò&¤s¨3£x´°T·W±W¸XÓ5IÓ1J×KÓKÙñ <ð ä×"Ò"¤3 s£8¬S°·±¸Ó1BÓ-CÓDÐDr   Úissuer_namec                 óô   • [         R                  " U R                  U(       a  UOU R                  4U(       a  UOU R                  U R                  5       R                  U R                  U R                  S.UD6$ )zá
Returns the provisioning URI for the OTP.  This can then be
encoded in a QR Code and used to provision an OTP app like
Google Authenticator.

See also:
    https://github.com/google/google-authenticator/wiki/Key-Uri-Format

)r   Ú	algorithmr   Úperiod)r   Ú	build_uriÚsecretr   r   r   r   r   )r   r   r7   Úkwargss       r   Úprovisioning_uriÚTOTP.provisioning_uriX   s`   € ô �ŠØ�K‰KÞ‰D˜dŸi™ið
ö #.‘;°4·;±;Ø—k‘k“m×(Ñ(Ø—;‘;Ø—=‘=ñ
ð ñ
ð 	
r   c                 ó  • UR                   (       a:  [        [        R                  " UR	                  5       5      U R
                  -  5      $ [        [        R                  " UR                  5       5      U R
                  -  5      $ )zŸ
Accepts either a timezone naive (`for_time.tzinfo is None`) or
a timezone aware datetime as argument and returns the
corresponding counter value (timecode).

)	Útzinfor&   ÚcalendarÚtimegmÚutctimetupler   ÚtimeÚmktimeÚ	timetuple)r   r    s     r   r(   ÚTOTP.timecodel   sW   € ð �?�?Ü”x—’ x×'<Ñ'<Ó'>Ó?À$Ç-Á-ÑOÓPÐPä”t—{’{ 8×#5Ñ#5Ó#7Ó8¸4¿=¹=ÑHÓIÐIr   )r   )é   NNNé   )r   )Nr   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r3   r&   r   r   r   r   r$   r)   r,   Úboolr5   r>   r(   Ú__static_attributes__Ú__classcell__)r   s   @r   r
   r
      s.  ø† ñð ØØ"Ø $ØñVàðVð ðVð ð	Vð
 �s‰mðVð ˜‘ðVð ðVð 
÷Vð Vñ2K˜5  h×&7Ñ&7Ð!7Ñ8ð KÈ#ð KÐVYõ Kð&I�Sô IñE˜#ð E¨°(×2CÑ2CÑ)Dð EÐ[^ð EÐgkõ Eñ(
 X¨c¡]ð 
ÈÐQTÉð 
Ðknõ 
ð(
J ×!2Ñ!2ð 
J°s÷ 
Jò 
Jr   r
   )rB   r$   r   rE   Útypingr   r   r   Ú r   r.   r   r
   © r   r   Ú<module>rV      s-   ðÛ Û Û Û ß 'Ñ 'å Ý ôkJˆ3õ kJr   