
    i
                        S SK Jr  S SKrS SKrS SKJr  S SKJr  SSKJ	r	J
r
Jr  SSKJrJrJrJrJr  SSKJr   " S	 S
5      r " S S5      r " S S5      rg)    )annotationsN)Iterator)Any   )get_default_algorithms
has_cryptorequires_cryptography)InvalidKeyErrorMissingCryptographyError
PyJWKErrorPyJWKSetError
PyJWTError)JWKDictc                      \ rS rSrS
SS jjr\S
SS jj5       r\S
SS jj5       r\SS j5       r	\SS j5       r
\SS j5       rS	rg)PyJWK   Nc                   Xl         U R                   R                  SS5      nU(       d  [        SU R                    35      eU(       d;  [        U R                   [        5      (       a  U R                   R                  SS5      nU(       d  U R                   R                  SS5      nUS:X  a9  US:X  d  U(       d  SnOUS	:X  a  S
nO|US:X  a  SnOsUS:X  a  SnOj[        SU 35      eUS:X  a  SnOSUS:X  a  SnOJUS:X  a6  U(       d  [        SU R                    35      eUS:X  a  SnO[        SU 35      e[        SU 35      e[
        (       d  U[        ;   a  [        U S35      eX l         [        5       U   U l
        U R                  R                  U R                   5      U l        g! [         a    [        SU R                    35      Sef = f)aS  A class that represents a `JSON Web Key <https://www.rfc-editor.org/rfc/rfc7517>`_.

:param jwk_data: The decoded JWK data.
:type jwk_data: dict[str, typing.Any]
:param algorithm: The key algorithm. If not specified, the key's ``alg`` will be used.
:type algorithm: str or None
:raises InvalidKeyError: If the key type (``kty``) is not found or unsupported, or if the curve (``crv``) is not found or unsupported.
:raises MissingCryptographyError: If the algorithm requires ``cryptography`` to be installed and it is not available.
:raises PyJWKError: If unable to find an algorithm for the key.
ktyNzkty is not found: algcrvECzP-256ES256zP-384ES384zP-521ES512	secp256k1ES256KzUnsupported crv: RSARS256octHS256OKPzcrv is not found: Ed25519EdDSAzUnsupported kty: z) requires 'cryptography' to be installed.z%Unable to find an algorithm for key: )	_jwk_datagetr
   
isinstancedictr   r	   r   algorithm_namer   	AlgorithmKeyErrorr   from_jwkkey)selfjwk_data	algorithmr   r   s        V/home/maestro/MAESTRO/maestro-backend/venv/lib/python3.13/site-packages/jwt/api_jwk.py__init__PyJWK.__init__   s    "nn  -!$6t~~6F"GHHZ==**5$7I..$$UD1Cd{'> 'IG^ 'IG^ 'IK' (I),=cU*CDD#	#	),>t~~>N*OPP)# 'I),=cU*CDD%(9#&?@@zi+@@*+FG  (	35i@DN >>**4>>:  	77GH	s   ,F) )$Gc                    [        X5      $ )a  Creates a :class:`PyJWK` object from a JSON-like dictionary.

:param obj: The JWK data, as a dictionary
:type obj: dict[str, typing.Any]
:param algorithm: The key algorithm. If not specified, the key's ``alg`` will be used.
:type algorithm: str or None
:rtype: PyJWK
)r   )objr/   s     r0   	from_dictPyJWK.from_dictT   s     S$$    c                X    [         R                  " U 5      n[        R                  X!5      $ )a  Create a :class:`PyJWK` object from a JSON string.
Implicitly calls :meth:`PyJWK.from_dict()`.

:param str data: The JWK data, as a JSON string.
:param algorithm:  The key algorithm.  If not specific, the key's ``alg`` will be used.
:type algorithm: str or None

:rtype: PyJWK
)jsonloadsr   r5   )datar/   r4   s      r0   	from_jsonPyJWK.from_json`   s!     jjs..r7   c                :    U R                   R                  SS5      $ )z6The `kty` property from the JWK.

:rtype: str or None
r   Nr$   r%   r-   s    r0   key_typePyJWK.key_typen        ~~!!%..r7   c                :    U R                   R                  SS5      $ )z6The `kid` property from the JWK.

:rtype: str or None
kidNr?   r@   s    r0   key_idPyJWK.key_idv   rC   r7   c                :    U R                   R                  SS5      $ )z6The `use` property from the JWK.

:rtype: str or None
useNr?   r@   s    r0   public_key_usePyJWK.public_key_use~   rC   r7   )r)   r$   r(   r,   N)r.   r   r/   
str | NonereturnNone)r4   r   r/   rM   rN   r   )r;   strr/   rO   rN   r   )rN   rM   )__name__
__module____qualname____firstlineno__r1   staticmethodr5   r<   propertyrA   rF   rJ   __static_attributes__ r7   r0   r   r      sl    >;@ 	% 	% / / / / / / / /r7   r   c                  Z    \ rS rSrS	S jr\S
S j5       r\SS j5       rSS jrSS jr	Sr
g)PyJWKSet   c                x   / U l         U(       d  [        S5      e[        U[        5      (       d  [        S5      eU H(  n U R                   R	                  [        U5      5        M*     [        U R                   5      S:X  a  [        S5      eg ! [         a"  n[        U[        5      (       a  Ue S nAMx  S nAff = f)Nz$The JWK Set did not contain any keyszInvalid JWK Set valuer   zUThe JWK Set did not contain any usable keys. Perhaps 'cryptography' is not installed?)	keysr   r&   listappendr   r   r   len)r-   r]   r,   errors       r0   r1   PyJWKSet.__init__   s    !#	 FGG$%% 788C		  s,  tyy>Qg    e%=>>K	s    $B
B9B44B9c                <    U R                  S/ 5      n[        U5      $ )Nr]   )r%   rZ   )r4   r]   s     r0   r5   PyJWKSet.from_dict   s    wwvr"~r7   c                X    [         R                  " U 5      n[        R                  U5      $ rL   )r9   r:   rZ   r5   )r;   r4   s     r0   r<   PyJWKSet.from_json   s!    jj!!#&&r7   c                l    U R                    H  nUR                  U:X  d  M  Us  $    [        SU 35      e)Nzkeyset has no key for kid: )r]   rF   r*   )r-   rE   r,   s      r0   __getitem__PyJWKSet.__getitem__   s6    99CzzS 
  4SE:;;r7   c                ,    [        U R                  5      $ rL   )iterr]   r@   s    r0   __iter__PyJWKSet.__iter__   s    DIIr7   )r]   N)r]   zlist[JWKDict]rN   rO   )r4   zdict[str, Any]rN   rZ   )r;   rP   rN   rZ   )rE   rP   rN   r   )rN   zIterator[PyJWK])rQ   rR   rS   rT   r1   rU   r5   r<   rh   rl   rW   rX   r7   r0   rZ   rZ      s9    .   ' '<r7   rZ   c                  2    \ rS rSrSS jrSS jrS	S jrSrg)
PyJWTSetWithTimestamp   c                D    Xl         [        R                  " 5       U l        g rL   )jwk_settime	monotonic	timestamp)r-   rr   s     r0   r1   PyJWTSetWithTimestamp.__init__   s    )r7   c                    U R                   $ rL   )rr   r@   s    r0   get_jwk_set!PyJWTSetWithTimestamp.get_jwk_set   s    ||r7   c                    U R                   $ rL   )ru   r@   s    r0   get_timestamp#PyJWTSetWithTimestamp.get_timestamp   s    ~~r7   )rr   ru   N)rr   rZ   )rN   rZ   )rN   float)rQ   rR   rS   rT   r1   rx   r{   rW   rX   r7   r0   ro   ro      s    *r7   ro   )
__future__r   r9   rs   collections.abcr   typingr   
algorithmsr   r   r	   
exceptionsr
   r   r   r   r   typesr   r   rZ   ro   rX   r7   r0   <module>r      sK    "   $  Q Q  q/ q/h) )X	 	r7   