Ë
    %V.jŒ  ã                   óÐ   — d dl Z d dlZd dlmZmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZmZ d dlmZmZ de
j"                  fd„Zdd	„Zd
„ Zd„ Zd„ Zdd„Zd„ Zd„ Zd„ Zd„ Zd„ Zdd„Zy)é    N)ÚIterableÚMapping)Újwk)ÚKey)Ú
ALGORITHMS)ÚJWSErrorÚJWSSignatureError)Úbase64url_decodeÚbase64url_encodec                 ó’   — |t         j                  vrt        d|z  «      ‚t        ||¬«      }t	        | «      }t        ||||«      }|S )aw  Signs a claims set and returns a JWS string.

    Args:
        payload (str or dict): A string to sign
        key (str or dict): The key to use for signing the claim set. Can be
            individual JWK or JWK set.
        headers (dict, optional): A set of headers that will be added to
            the default headers.  Any headers that are added as additional
            headers will override the default headers.
        algorithm (str, optional): The algorithm to use for signing the
            the claims.  Defaults to HS256.

    Returns:
        str: The string representation of the header, claims, and signature.

    Raises:
        JWSError: If there is an error signing the token.

    Examples:

        >>> jws.sign({'a': 'b'}, 'secret', algorithm='HS256')
        'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhIjoiYiJ9.jiMyrsmD8AoHWeQgmxZ5yq8z0lXS67_QGs52AzC8Ru8'

    zAlgorithm %s not supported.)Úadditional_headers)r   Ú	SUPPORTEDr   Ú_encode_headerÚ_encode_payloadÚ_sign_header_and_claims)ÚpayloadÚkeyÚheadersÚ	algorithmÚencoded_headerÚencoded_payloadÚsigned_outputs          úJC:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\jose/jws.pyÚsignr      sP   € ð4 œ
×,Ñ,Ñ,ÜÐ4°yÑ@ÓAÐAä# IÀ'ÔJ€NÜ% gÓ.€OÜ+¨N¸OÈYÐX[Ó\€MàÐó    c                 óH   — t        | «      \  }}}}|rt        |||||«       |S )a£  Verifies a JWS string's signature.

    Args:
        token (str): A signed JWS to be verified.
        key (str or dict): A key to attempt to verify the payload with. Can be
            individual JWK or JWK set.
        algorithms (str or list): Valid algorithms that should be used to verify the JWS.

    Returns:
        str: The str representation of the payload, assuming the signature is valid.

    Raises:
        JWSError: If there is an exception verifying a token.

    Examples:

        >>> token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhIjoiYiJ9.jiMyrsmD8AoHWeQgmxZ5yq8z0lXS67_QGs52AzC8Ru8'
        >>> jws.verify(token, 'secret', algorithms='HS256')

    )Ú_loadÚ_verify_signature)Útokenr   Ú
algorithmsÚverifyÚheaderr   Úsigning_inputÚ	signatures           r   r!   r!   0   s.   € ô, 16°e³Ñ-€FˆG�] IáÜ˜-¨°¸CÀÔLà€Nr   c                 ó&   — t        | «      \  }}}}|S )a!  Returns the decoded headers without verification of any kind.

    Args:
        token (str): A signed JWS to decode the headers from.

    Returns:
        dict: The dict representation of the token headers.

    Raises:
        JWSError: If there is an exception decoding the token.
    ©r   ©r   r"   Úclaimsr#   r$   s        r   Úget_unverified_headerr)   N   ó   € ô 05°U«|Ñ,€FˆF�M 9Ø€Mr   c                 ó   — t        | «      S )a{  Returns the decoded headers without verification of any kind.

    This is simply a wrapper of get_unverified_header() for backwards
    compatibility.

    Args:
        token (str): A signed JWS to decode the headers from.

    Returns:
        dict: The dict representation of the token headers.

    Raises:
        JWSError: If there is an exception decoding the token.
    )r)   )r   s    r   Úget_unverified_headersr,   ^   s   € ô ! Ó'Ð'r   c                 ó&   — t        | «      \  }}}}|S )a  Returns the decoded claims without verification of any kind.

    Args:
        token (str): A signed JWS to decode the headers from.

    Returns:
        str: The str representation of the token claims.

    Raises:
        JWSError: If there is an exception decoding the token.
    r&   r'   s        r   Úget_unverified_claimsr.   p   r*   r   c                 ó–   — d| dœ}|r|j                  |«       t        j                  |dd¬«      j                  d«      }t	        |«      S )NÚJWT)ÚtypÚalg©Ú,Ú:T)Ú
separatorsÚ	sort_keysúutf-8)ÚupdateÚjsonÚdumpsÚencoder   )r   r   r"   Újson_headers       r   r   r   €   sN   € Ø 9Ñ-€FáØ�‰Ð(Ô)ä—*‘*ØØØô÷ �fˆWƒoð	 ô ˜KÓ(Ð(r   c                 óÎ   — t        | t        «      r2	 t        j                  | d¬«      j	                  d«      } t        | «      S t        | «      S # t
        $ r Y t        | «      S w xY w)Nr3   )r6   r8   )Ú
isinstancer   r:   r;   r<   Ú
ValueErrorr   )r   s    r   r   r   �   sj   € Ü�'œ7Ô#ð	Ü—j‘jØØ%ô÷ ‰f�W‹oð ô ˜GÓ$Ð$Ô˜GÓ$Ð$øô ò 	Øä˜GÓ$Ð$ð	ús   ’&A Á	A$Á#A$c                 ó0  — dj                  | |g«      }	 t        |t        «      st        j                  ||«      }|j                  |«      }t        |«      }dj                  | ||g«      }|j                  d«      S # t        $ r}t        |«      ‚d }~ww xY w)Nó   .r8   )
Újoinr?   r   r   Ú	constructr   Ú	Exceptionr   r   Údecode)	r   Úencoded_claimsr   r   r#   r$   ÚeÚencoded_signatureÚencoded_strings	            r   r   r   œ   s’   € Ø—I‘I˜~¨~Ð>Ó?€MðÜ˜#œsÔ#Ü—-‘-  YÓ/ˆCØ—H‘H˜]Ó+ˆ	ô )¨Ó3Ðà—Y‘Y °Ð@QÐRÓS€Nà× Ñ  Ó)Ð)øô ò Ü�q‹kÐûðús   •7A< Á<	BÂBÂBc                 óÀ  — t        | t        «      r| j                  d«      } 	 | j                  dd«      \  }}|j	                  dd«      \  }}t        |«      }	 t        j                  |j                  d«      «      }t        |t        «      st        d«      ‚	 t        |«      }	 t        |«      }	||||	fS # t        $ r t        d«      ‚t        t        j                  f$ r t        d«      ‚w xY w# t        $ r}t        d|z  «      ‚d }~ww xY w# t        t        j                  f$ r t        d«      ‚w xY w# t        t        j                  f$ r t        d	«      ‚w xY w)
Nr8   rB   é   zNot enough segmentszInvalid header paddingzInvalid header string: %sz,Invalid header string: must be a json objectzInvalid payload paddingzInvalid crypto padding)r?   Ústrr<   ÚrsplitÚsplitr
   r@   r   Ú	TypeErrorÚbinasciiÚErrorr:   ÚloadsrF   r   )
Újwtr#   Úcrypto_segmentÚheader_segmentÚclaims_segmentÚheader_datar"   rH   r   r$   s
             r   r   r   ¬   s`  € Ü�#”sÔØ�j‰j˜Ó!ˆð1Ø(+¯
©
°4¸Ó(;Ñ%ˆ�~Ø)6×)<Ñ)<¸TÀ1Ó)EÑ&ˆ˜Ü& ~Ó6ˆð8Ü—‘˜K×.Ñ.¨wÓ7Ó8ˆô �fœgÔ&ÜÐEÓFÐFð2Ü" >Ó2ˆð1Ü$ ^Ó4ˆ	ð �G˜]¨IÐ6Ð6øô/ ò .ÜÐ,Ó-Ð-Ü”x—~‘~Ð&ò 1ÜÐ/Ó0Ð0ð1ûô
 ò 8ÜÐ2°QÑ6Ó7Ð7ûð8ûô ”x—~‘~Ð&ò 2ÜÐ0Ó1Ð1ð2ûô
 ”x—~‘~Ð&ò 1ÜÐ/Ó0Ð0ð1ús;   £5B6 Á$C1 ÂD Â%D8 Â68C.Ã1	DÃ:DÄDÄ%D5Ä8%Ec                 ó¦   — | D ]=  }t        |t        «      st        j                  ||«      }	 |j	                  ||«      r yŒ? y# t
        $ r Y ŒLw xY w)NTF)r?   r   r   rD   r!   rE   )Úkeysr#   r$   r2   r   s        r   Ú_sig_matches_keysr[   Í   sZ   € ÛˆÜ˜#œsÔ#Ü—-‘-  SÓ)ˆCð	Ø�z‰z˜-¨Ô3Ùð 4ð	 ð øô ò 	Ùð	ús   ­AÁ	AÁAc                 ó`  — t        | t        «      r| fS 	 t        j                  | t        t        ¬«      } t        | t        «      r'd| v r| d   S d| v r| fS | j                  «       }|r|S | fS t        | t        «      r"t        | t        «      st        | t        «      s| S | fS # t
        $ r Y Œww xY w)N)Ú	parse_intÚparse_floatrZ   Úkty)
r?   r   r:   rS   rM   rE   r   Úvaluesr   Úbytes)r   r`   s     r   Ú	_get_keysrb   Ù   s²   € ä�#”sÔØˆvˆðÜ�j‰j˜¬¼Ô=ˆô �#”wÔØ�S‰=à�v‘;ÐØ�c‰\à�6ˆMð —Z‘Z“\ˆFÙØ�Ø�6ˆMô 
�CœÔ	"¬J°s¼CÔ,@ÄJÈsÔTYÔDZØˆ
ð ˆvˆøô/ ò Ùðús   • B! Â!	B-Â,B-c                 ó  — |j                  d«      }|st        d«      ‚|�||vrt        d«      ‚t        |«      }	 t        || ||«      s
t	        «       ‚y # t        $ r t        d«      ‚t        $ r t        d|z  «      ‚w xY w)Nr2   z-No algorithm was specified in the JWS header.z&The specified alg value is not allowedzSignature verification failed.z$Invalid or unsupported algorithm: %s)Úgetr   rb   r[   r	   )r#   r"   r$   r   r    r2   rZ   s          r   r   r   ú   sš   € à
�*‰*�UÓ
€CÙÜÐFÓGÐGàÐ #¨ZÑ"7ÜÐ?Ó@Ð@ä�S‹>€DðEÜ   }°iÀÔEÜ#Ó%Ð%ð Føäò 9ÜÐ7Ó8Ð8Üò EÜÐ=ÀÑCÓDÐDðEús   ¼A Á+B )T)N)Ú N)rQ   r:   Úcollections.abcr   r   Újoser   Újose.backends.baser   Újose.constantsr   Újose.exceptionsr   r	   Ú
jose.utilsr
   r   ÚHS256r   r!   r)   r,   r.   r   r   r   r   r[   rb   r   © r   r   Ú<module>rn      sj   ðÛ Û ß -å Ý "Ý %ß 7ß 9ð  $¨z×/?Ñ/?ó !óHò<ò (ò$ó )ò
%ò*ò 7òB	òôBEr   