
    Pi$                     T   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
  \R                  \\4   r\R                  \   r\R                  \R"                  \   \4   r " S S	5      r " S
 S\5      r " S S\5      rS\S\R,                  \   4S jr " S S5      rg)    N   )_base64_alphabet)base64_decode)base64_encode)
want_bytes)BadSignaturec                   H    \ rS rSrSrS\S\S\4S jrS\S\S\S\4S jrS	r	g
)SigningAlgorithm   z_Subclasses must implement :meth:`get_signature` to provide
signature generation functionality.
keyvaluereturnc                     [        5       e)z2Returns the signature for the given key and value.)NotImplementedErrorselfr   r   s      e/var/www/html/backend/Backoffice_Marketplace/venv/lib/python3.13/site-packages/itsdangerous/signer.pyget_signatureSigningAlgorithm.get_signature   s    !##    sigc                 L    [         R                  " X0R                  X5      5      $ )z=Verifies the given signature matches the expected
signature.
)hmaccompare_digestr   )r   r   r   r   s       r   verify_signature!SigningAlgorithm.verify_signature   s      ""3(:(:3(FGGr    N)
__name__
__module____qualname____firstlineno____doc__bytesr   boolr   __static_attributes__r   r   r   r
   r
      sG    $ $u $ $HE H% He H Hr   r
   c                   .    \ rS rSrSrS\S\S\4S jrSrg)	NoneAlgorithm    zXProvides an algorithm that does not perform any signing and
returns an empty signature.
r   r   r   c                     g)Nr   r   r   s      r   r   NoneAlgorithm.get_signature%   s    r   r   N)r   r   r    r!   r"   r#   r   r%   r   r   r   r'   r'       s!     u  r   r'   c                       \ rS rSr% Sr\" \R                  5      r\	R                  \S'   SS\	R                  4S jjrS\S\S	\4S
 jrSrg)HMACAlgorithm)   z*Provides signature generation using HMACs.default_digest_methodNdigest_methodc                 .    Uc  U R                   nXl        g N)r.   r/   )r   r/   s     r   __init__HMACAlgorithm.__init__1   s      66M%2r   r   r   r   c                 `    [         R                  " XU R                  S9nUR                  5       $ )N)msg	digestmod)r   newr/   digest)r   r   r   macs       r   r   HMACAlgorithm.get_signature7   s$    hhs1C1CDzz|r   )r/   r1   )r   r   r    r!   r"   staticmethodhashlibsha1r.   _tAny__annotations__r2   r#   r   r%   r   r   r   r,   r,   )   sI    4
 %1$>266>3bff 3 u  r   r,   
secret_keyr   c                     [        U [        [        45      (       a  [        U 5      /$ U  Vs/ s H  n[        U5      PM     sn$ s  snf r1   )
isinstancestrr#   r   )rA   ss     r   _make_keys_listrF   <   s=    *sEl++:&''#-.:aJqM:...s   Ac                      \ rS rSr% Sr\" \R                  5      r\	R                  \S'   Sr\\S'        SS\S\S	\S
\	R"                  \   S\	R"                  \	R                     S\	R"                  \   4S jjr\S\4S j5       rSS\S\4S jjrS\S\4S jrS\S\4S jrS\S\S\4S jrS\S\4S jrS\S\4S jrSrg)SignerC   a^  A signer securely signs bytes, then unsigns them to verify that
the value hasn't been changed.

The secret key should be a random string of ``bytes`` and should not
be saved to code or version control. Different salts should be used
to distinguish signing in different contexts. See :doc:`/concepts`
for information about the security of the secret key and salt.

:param secret_key: The secret key to sign and verify with. Can be a
    list of keys, oldest to newest, to support key rotation.
:param salt: Extra key to combine with ``secret_key`` to distinguish
    signatures in different contexts.
:param sep: Separator between the signature and value.
:param key_derivation: How to derive the signing key from the secret
    key and salt. Possible values are ``concat``, ``django-concat``,
    or ``hmac``. Defaults to :attr:`default_key_derivation`, which
    defaults to ``django-concat``.
:param digest_method: Hash function to use when generating the HMAC
    signature. Defaults to :attr:`default_digest_method`, which
    defaults to :func:`hashlib.sha1`. Note that the security of the
    hash alone doesn't apply when used intermediately in HMAC.
:param algorithm: A :class:`SigningAlgorithm` instance to use
    instead of building a default :class:`HMACAlgorithm` with the
    ``digest_method``.

.. versionchanged:: 2.0
    Added support for key rotation by passing a list to
    ``secret_key``.

.. versionchanged:: 0.18
    ``algorithm`` was added as an argument to the class constructor.

.. versionchanged:: 0.14
    ``key_derivation`` and ``digest_method`` were added as arguments
    to the class constructor.
r.   django-concatdefault_key_derivationNrA   saltsepkey_derivationr/   	algorithmc                 @   [        U5      U l        [        U5      U l        U R                  [        ;   a  [        S5      eUb  [        U5      nOSnX l        Uc  U R                  nX@l        Uc  U R                  nXPl
        Uc  [        U R                  5      nX`l        g )NzThe given separator cannot be used because it may be contained in the signature itself. ASCII letters, digits, and '-_=' must not be used.   itsdangerous.Signer)rF   secret_keysr   rM   r   
ValueErrorrL   rK   rN   r.   r/   r,   rO   )r   rA   rL   rM   rN   r/   rO   s          r   r2   Signer.__init__x   s     ,;:+F$S/88''7  d#D)D	!!88N#1  66M%2%d&8&89I+4r   r   c                      U R                   S   $ )zThe newest (last) entry in the :attr:`secret_keys` list. This
is for compatibility from before key rotation support was added.
)rR   )r   s    r   rA   Signer.secret_key   s    
 ##r   c                    Uc  U R                   S   nO[        U5      nU R                  S:X  aE  [        R                  " [
        U R                  U R                  U-   5      R                  5       5      $ U R                  S:X  aH  [        R                  " [
        U R                  U R                  S-   U-   5      R                  5       5      $ U R                  S:X  aI  [        R                  " XR                  S9nUR                  U R                  5        UR                  5       $ U R                  S:X  a  U$ [        S5      e)	a  This method is called to derive the key. The default key
derivation choices can be overridden here. Key derivation is not
intended to be used as a security method to make a complex key
out of a short password. Instead you should use large random
secret keys.

:param secret_key: A specific secret key to derive from.
    Defaults to the last item in :attr:`secret_keys`.

.. versionchanged:: 2.0
    Added the ``secret_key`` parameter.
rV   concatrJ   s   signerr   )r6   nonezUnknown key derivation method)rR   r   rN   r>   castr#   r/   rL   r8   r   r7   update	TypeError)r   rA   r9   s      r   
derive_keySigner.derive_key   s    ))"-J#J/J(*775$"4"4TYY5K"L"S"S"UVV  O377t))$))i*?**LMTTV    F*((:1C1CDCJJtyy!::<  F*;<<r   r   c                     [        U5      nU R                  5       nU R                  R                  X!5      n[	        U5      $ )z*Returns the signature for the given value.)r   r^   rO   r   r   )r   r   r   r   s       r   r   Signer.get_signature   s7    5!oonn**36S!!r   c                 X    [        U5      nXR                  -   U R                  U5      -   $ )zSigns the given string.)r   rM   r   )r   r   s     r   signSigner.sign   s)    5!xx$"4"4U";;;r   r   c                      [        U5      n[        U5      n[        U R                  5       H7  nU R                  U5      nU R                  R                  XAU5      (       d  M7    g   g! [         a     gf = f)z+Verifies the signature for the given value.FT)r   	Exceptionr   reversedrR   r^   rO   r   )r   r   r   rA   r   s        r   r   Signer.verify_signature   ss    	$C 5!"4#3#34J//*-C~~..s3??	 5   		s   A) )
A65A6signed_valuec                     [        U5      nU R                  U;  a  [        SU R                  < S35      eUR                  U R                  S5      u  p#U R	                  X#5      (       a  U$ [        SU< S3US9e)zUnsigns the given string.zNo z found in valuer   z
Signature z does not match)payload)r   rM   r   rsplitr   )r   ri   r   r   s       r   unsignSigner.unsign   st    !,/88<'TXXL@AA!((15
  ,,LZwo>NNr   c                 H     U R                  U5        g! [         a     gf = f)z^Only validates the given signed value. Returns ``True`` if
the signature exists and is valid.
TF)rm   r   )r   ri   s     r   validateSigner.validate   s(    	KK% 		s    
!!)rO   r/   rN   rL   rR   rM   )rQ      .NNNr1   )r   r   r    r!   r"   r;   r<   r=   r.   r>   r?   r@   rK   rD   _t_secret_key_t_opt_str_bytes_t_str_bytesOptionalr
   r2   propertyr#   rA   r^   r   rc   r$   r   rm   rp   r%   r   r   r   rH   rH   C   s9   #V %1$>266> #2C1
 "8 +/-137,5!,5 ,5 	,5
 C(,5 {{266*,5 ;;/0,5\ $E $ $=%5 = =B"< "E "<, <5 <
l  $ "O< OE O\ d r   rH   )r<   r   typingr>   encodingr   r   r   r   excr   UnionrD   r#   ru   rv   rt   Iterablers   r
   r'   r,   ListrF   rH   r   r   r   <module>r~      s       & # #   xxU
#;;|, \2L@AH H $ $ &/ /"''%. /~ ~r   