
    Pi                     `   S SK r S SKrS SKrS SKJr  S SKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SS	KJ
r
  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  \R&                  \\4   r\R.                  \   r\R.                  \   r\R6                  (       a  S SKr " S S\5      r " S S\5      rg)    N)datetime)timezone   )base64_decode)base64_encode)bytes_to_int)int_to_bytes)
want_bytes)BadSignature)BadTimeSignature)SignatureExpired)
Serializer)Signerc                   n  ^  \ rS rSrSrS\4S jrS\S\4S jrS\	S\
4S jr\R                    SS	\	S
\SSS\
4S jj5       r\R                    SS	\	S
\SSS\R"                  \
\4   4S jj5       r  SS	\	S
\S\S\R&                  \R"                  \
\4   \
4   4U 4S jjjrSS	\	S
\S\4S jjrSrU =r$ )TimestampSigner   zWorks like the regular :class:`.Signer` but also records the time
of the signing and can be used to expire signatures. The
:meth:`unsign` method can raise :exc:`.SignatureExpired` if the
unsigning failed because the signature is expired.
returnc                 >    [        [        R                  " 5       5      $ )zDReturns the current timestamp. The function must return an
integer.
)inttime)selfs    d/var/www/html/backend/Backoffice_Marketplace/venv/lib/python3.13/site-packages/itsdangerous/timed.pyget_timestampTimestampSigner.get_timestamp!   s     499;    tsc                 H    [         R                  " U[        R                  S9$ )zConvert the timestamp from :meth:`get_timestamp` into an
aware :class`datetime.datetime` in UTC.

.. versionchanged:: 2.0
    The timestamp is returned as a timezone-aware ``datetime``
    in UTC rather than a naive ``datetime`` assumed to be UTC.
)tz)r   fromtimestampr   utc)r   r   s     r   timestamp_to_datetime%TimestampSigner.timestamp_to_datetime'   s     %%bX\\::r   valuec                     [        U5      n[        [        U R                  5       5      5      n[        U R                  5      nX-   U-   nX-   U R                  U5      -   $ )z:Signs the given string and also attaches time information.)r
   r   r	   r   sepget_signature)r   r#   	timestampr%   s       r   signTimestampSigner.sign1   sV    5!!,t/A/A/C"DE	"i'{T//666r   signed_valuemax_agereturn_timestampz_te.Literal[False]c                     g N r   r*   r+   r,   s       r   unsignTimestampSigner.unsign<        	r   z_te.Literal[True]c                     g r.   r/   r0   s       r   r1   r2   E   r3   r   c                   >  [         TU ]  U5      nSn[	        U R
                  5      nXt;  a  U(       a  Ue[        SUS9eUR                  US5      u  pSn
Sn [        [        U	5      5      n
Ub(  U
b   U R                  U
5      n[        [        U5      XS9eU
c
  [        SUS9eUb]  U R!                  5       U
-
  nX:  a!  [#        SU S	U S
3UU R                  U
5      S9eUS:  a  [#        SU S3UU R                  U
5      S9eU(       a  XR                  U
5      4$ U$ ! [         a"  nUnUR                  =(       d    Sn SnAGN4SnAff = f! [         a     Nf = f! [        [        [        4 a  n[        SUS9UeSnAff = f)a  Works like the regular :meth:`.Signer.unsign` but can also
validate the time. See the base docstring of the class for
the general behavior. If ``return_timestamp`` is ``True`` the
timestamp of the signature will be returned as an aware
:class:`datetime.datetime` object in UTC.

.. versionchanged:: 2.0
    The timestamp is returned as a timezone-aware ``datetime``
    in UTC rather than a naive ``datetime`` assumed to be UTC.
Nr   ztimestamp missing)payloadr   zMalformed timestamp)r6   date_signedzSignature age z > z secondsr   z < 0 seconds)superr1   r   r6   r
   r%   r   rsplitr   r   	Exceptionr!   
ValueErrorOSErrorOverflowErrorstrr   r   )r   r*   r+   r,   result	sig_errorer%   r#   ts_bytests_intts_dtexcage	__class__s                 r   r1   r2   N   s    	&W^L1FI
 " "#6GG --Q/!'+	!-"9:F  ! 66v>E #3y>5TT >"#8%HH $$&/C}&$SEWIX>! $ : :6 B  Qw&$SE6! $ : :6 B  44V<<<G  	&IYY%#F	&.  		 #G];  +-usA   D! E 5E  !
E+EE
EE F5F  Fc                 D     U R                  XS9  g! [         a     gf = f)z]Only validates the given signed value. Returns ``True`` if
the signature exists and is valid.)r+   TF)r1   r   )r   r*   r+   s      r   validateTimestampSigner.validate   s*    	KKK6 		s    
r/   )NF)NTr.   )__name__
__module____qualname____firstlineno____doc__r   r   r   r!   _t_str_bytesbytesr(   typingoverload
_t_opt_intr1   _tTupleboolUnionrI   __static_attributes____classcell__rG   s   @r   r   r      sM    s  ; ; ;7, 75 7 __ #16	"  /	
 
  __ #04	"  .	
 
%/	"  #!&	V"V V 	V
 
"((5(?+U2	3V Vp\ J RV  r   r   c                     ^  \ rS rSr% Sr\r\R                  \   \	S'    SS\
S\R                  \   4U 4S jjjr   SS\S\S	\S\
S\R                   4
S
 jjr  SS\S\S\
S\R$                  \\R                   4   4S jjrSrU =r$ )TimedSerializer   zGUses :class:`TimestampSigner` instead of the default
:class:`.Signer`.
default_signersaltr   c                 L   > [         R                  " S[        TU ]  U5      5      $ )Nz_t.Iterator[TimestampSigner])rU   castr8   iter_unsigners)r   r`   rG   s     r   rc   TimedSerializer.iter_unsigners   s!     ww5uw7Md7STTr   sr+   r,   c                 .   [        U5      nSnU R                  U5       H5  n UR                  XSS9u  pxU R                  U5      n	U(       a  X4s  $ U	s  $    [        R                  " [
        U5      e! [         a    e [
         a  n
U
n Sn
A
Mp  Sn
A
ff = f)aV  Reverse of :meth:`dumps`, raises :exc:`.BadSignature` if the
signature validation fails. If a ``max_age`` is provided it will
ensure the signature is not older than that time in seconds. In
case the signature is outdated, :exc:`.SignatureExpired` is
raised. All arguments are forwarded to the signer's
:meth:`~TimestampSigner.unsign` method.
NT)r+   r,   )r
   rc   r1   load_payloadr   r   rU   rb   )r   re   r+   r,   r`   last_exceptionsignerbase64dr'   r6   errs              r   loadsTimedSerializer.loads   s     qM))$/F%%+]] &3 &" ++G4#"-- 0$ gglN33 $   %!$%s   ,A3A33BBBc                 &    U R                  XSU0S9$ )Nr+   )load_kwargs)_loads_unsafe_impl)r   re   r+   r`   s       r   loads_unsafeTimedSerializer.loads_unsafe   s     &&qY<P&QQr   r/   r.   )NFN)NN)rK   rL   rM   rN   rO   r   r_   rU   Type__annotations___t_opt_str_bytesIteratorrc   rP   rT   rW   Anyrl   rV   rq   rY   rZ   r[   s   @r   r]   r]      s     0?NBGGO,> (,U$U	_	%U U #!&!%#4#4 #4 	#4
 #4 
#4P #!%	RR R 	R
 
$,	R Rr   r]   ) r   rR   rU   r   r   encodingr   r   r   r	   r
   rE   r   r   r   
serializerr   ri   r   rX   r>   rQ   rP   Optionalru   r   rT   TYPE_CHECKINGtyping_extensions_ter   r]   r/   r   r   <module>r~      s         # # " "    ! ! " xxU
#;;|, [[
#Sf Sl:Rj :Rr   