
    kKj                        d dl Z d dl mZmZ d dlmZ ddlmZmZmZm	Z	m
Z
 ddlmZ ddlmZmZmZ ddlmZmZmZ dd	lmZ dd
lmZ ddlmZ ddlmZ g dZ G d d      Z	 	 	 	 ddedededee   dz  deez  dz  de e   dz  dedz  defdZ!	 	 	 dde"ez  dedee   dz  deez  dz  de e   dz  defdZ#	 d de"dedee   dz  dedz  de$ee"f   f
dZ%	 d de"dedee   dz  dedz  de$ee"f   f
dZ&y)!    N)JSONEncoderJSONDecoder)
Collection   )convert_claimsClaimsClaimsOptionBaseClaimsRegistryJWTClaimsRegistry)check_sensitive_data)JWSRegistryserialize_compactdeserialize_compact)JWERegistryencrypt_compactdecrypt_compact)KeyFlexible)InvalidPayloadError)to_bytes)Header)r   r	   r
   r   Tokenencodedecoder   c                        e Zd ZdZdedefdZy)r   zThe extracted token object, which contains ``header`` and ``claims``.

    :param header: the header part of the JWT
    :param claims: the payload part of the JWT
    headerclaimsc                      || _         || _        y N)r   r   )selfr   r   s      \/Users/ahmed/devFolder/Ultron/claude-voice/.venv/lib/python3.12/site-packages/joserfc/jwt.py__init__zToken.__init__1   s        N)__name__
__module____qualname____doc__r   r   r!    r"   r    r   r   *   s    v v r"   r   r   r   key
algorithmsregistryencoder_clsdefault_typereturnc                     |d|i| }ni | }t        ||      }t        |t              rt        |||||      S t	        |||||      S )a  Encode a JSON Web Token with the given header, and claims.

    :param header: A dict of the JWT header
    :param claims: A dict of the JWT claims to be encoded
    :param key: key used to sign the signature
    :param algorithms: a collection (list, tuple, or set) of allowed algorithms
    :param registry: a ``JWSRegistry`` or ``JWERegistry`` to use
    :param encoder_cls: A JSONEncoder subclass to use
    :param default_type: default value of the ``typ`` header parameter
    typ)r   
isinstancer   r   r   )	r   r   r(   r)   r*   r+   r,   _headerpayloads	            r    r   r   8   s^    & ,1&1V*V[1G(K(wj(KK '3
HMMr"   valuedecoder_clsc                     t        |       }t        |t              rt        ||||      \  }}nt	        ||||      \  }}	 t        j                  ||      }t        ||      S # t        t        f$ r t               w xY w)a
  Decode the JSON Web Token string with the given key, and validate
    it with the claims requests.

    :param value: text of the JWT
    :param key: key used to verify the signature
    :param algorithms: a collection (list, tuple, or set) of allowed algorithms
    :param registry: a ``JWSRegistry`` or ``JWERegistry`` to use
    :param decoder_cls: A JSONDecoder subclass to use
    :raise BadSignatureError: when signature verification fails
    :raise InvalidPayloadError: when payload is not a valid JSON object
    )cls)r   r0   r   _decode_jwe_decode_jwsjsonloads	TypeError
ValueErrorr   r   )	r3   r(   r)   r*   r4   _valuer   r2   r   s	            r    r   r   V   s    $ e_F (K(%fc:xH%fc:xH$G=    z" $!##$s    A# #A=c                 r    t        | |||      }|j                  J |j                         |j                  fS r   )r   	plaintextheaders)r3   r(   r)   r*   jwe_objs        r    r7   r7   x   s>     eS*h?G(((??g////r"   c                 r    t        | |||      }|j                  J |j                         |j                  fS r   )r   r2   r@   )r3   r(   r)   r*   jws_objs        r    r8   r8      s:     "%j(CG??&&&??goo--r"   )NNNJWT)NNN)NN)'r9   r   r   collections.abcr   _rfc7519.claimsr   r   r	   r
   r   _rfc7519.securityr   jwsr   r   r   jwer   r   r   jwkr   errorsr   utilr   r*   r   __all__r   strtyper   bytesr   tupler7   r8   r'   r"   r    <module>rR      s    ) &  4 
 
  '   $ *.15,0$NNN 
N 3$&	N
 K'$.N k"T)N *N 	NB *.15,0!3;!	! 3$&! K'$.	!
 k"T)! !F os00"00:3$0F0YdgkYk0
65=0 os..".0:3$0F.YdgkYk.
65=.r"   