Ë
    Í—ÄjE  ã                  ó°   — d dl mZ d dlZd dlZd dl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mZmZ ddlmZ  G d	„ d
«      Z G d„ d«      Z G d„ d«      Zy)é    )ÚannotationsN)ÚIterator)ÚAnyé   )Úget_default_algorithmsÚ
has_cryptoÚrequires_cryptography)ÚInvalidKeyErrorÚMissingCryptographyErrorÚ
PyJWKErrorÚPyJWKSetErrorÚ
PyJWTError)ÚJWKDictc                  ót   — e Zd Zdd	d„Zedd
d„«       Zeddd„«       Zedd„«       Zedd„«       Z	edd„«       Z
y)ÚPyJWKNc                ó”  — || _         | j                   j                  dd«      }|st        d| j                   › �«      ‚|s6t        | j                   t        «      r| j                   j                  dd«      }|s¤| j                   j                  dd«      }|dk(  r0|dk(  s|sd}ny|d	k(  rd
}nq|dk(  rd}ni|dk(  rd}nat        d|› �«      ‚|dk(  rd}nK|dk(  rd}nC|dk(  r0|st        d| j                   › �«      ‚|dk(  rd}nt        d|› �«      ‚t        d|› �«      ‚t
        s|t        v rt        |› d�«      ‚|| _        	 t        «       |   | _
        	 | j                  j                  | j                   «      | _        y# t        $ r t        d| j                   › �«      d‚w xY w# t        t         f$ r}t        d|› �«      |‚d}~ww xY w)a“  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: z"Unable to construct key from JWK: )Ú	_jwk_dataÚgetr
   Ú
isinstanceÚdictr   r	   r   Úalgorithm_namer   Ú	AlgorithmÚKeyErrorr   Úfrom_jwkÚkeyÚ	TypeErrorÚ
ValueError)ÚselfÚjwk_dataÚ	algorithmr   r   Úerrors         úPC:\Users\pivot\Documents\cueki\casual-preloader\Lib\site-packages\jwt/api_jwk.pyÚ__init__zPyJWK.__init__   sõ  € ð "ˆŒà�n‰n× Ñ  ¨Ó-ˆÙÜ!Ð$6°t·~±~Ð6FÐ"GÓHÐHáœZ¨¯©¼Ô=ØŸ™×*Ñ*¨5°$Ó7ˆIáà—.‘.×$Ñ$ U¨DÓ1ˆCØ�dŠ{Ø˜'’>©Ø '‘IØ˜G’^Ø '‘IØ˜G’^Ø '‘IØ˜KÒ'Ø (‘Iä)Ð,=¸c¸UÐ*CÓDÐDØ˜’Ø#‘	Ø˜’Ø#‘	Ø˜’ÙÜ)Ð,>¸t¿~¹~Ð>NÐ*OÓPÐPØ˜)Ò#Ø '‘Iä)Ð,=¸c¸UÐ*CÓDÐDä%Ð(9¸#¸Ð&?Ó@Ð@å˜iÔ+@Ñ@Ü*Ø�+ÐFÐGóð ð (ˆÔð	Ü3Ó5°iÑ@ˆDŒNð	Ø—~‘~×.Ñ.¨t¯~©~Ó>ˆD�Høô ò 	ÜØ7¸¿¹Ð7GÐHóàðð	ûô œ:Ð&ò 	Ü!Ø4°U°GÐ<óàðûð	ús$   Å E> Å*F$ Å>#F!Æ$GÆ3GÇGc                ó   — t        | |«      S )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   )Úobjr0   s     r2   Ú	from_dictzPyJWK.from_dictY   s   € ô �S˜)Ó$Ð$ó    c                óX   — t        j                  | «      }t        j                  ||«      S )aE  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   r6   )Údatar0   r5   s      r2   Ú	from_jsonzPyJWK.from_jsone   s#   € ô �j‰j˜ÓˆÜ�‰˜s IÓ.Ð.r7   c                ó:   — | j                   j                  dd«      S )zFThe `kty` property from the JWK.

        :rtype: str or None
        r   N©r#   r$   ©r.   s    r2   Úkey_typezPyJWK.key_types   ó   € ð �~‰~×!Ñ! %¨Ó.Ð.r7   c                ó:   — | j                   j                  dd«      S )zFThe `kid` property from the JWK.

        :rtype: str or None
        ÚkidNr>   r?   s    r2   Úkey_idzPyJWK.key_id{   rA   r7   c                ó:   — | j                   j                  dd«      S )zFThe `use` property from the JWK.

        :rtype: str or None
        ÚuseNr>   r?   s    r2   Úpublic_key_usezPyJWK.public_key_useƒ   rA   r7   ©N)r/   r   r0   ú
str | NoneÚreturnÚNone)r5   r   r0   rI   rJ   r   )r;   Ústrr0   rI   rJ   r   )rJ   rI   )Ú__name__Ú
__module__Ú__qualname__r3   Ústaticmethodr6   r<   Úpropertyr@   rD   rG   © r7   r2   r   r      sm   „ ôCðJ ó	%ó ð	%ð ó/ó ð/ð ò/ó ð/ð ò/ó ð/ð ò/ó ñ/r7   r   c                  óH   — e Zd Zdd„Zedd„«       Zed	d„«       Zd
d„Zdd„Zy)ÚPyJWKSetc                ór  — g | _         |st        d«      ‚t        |t        «      st        d«      ‚|D ]8  }t        |t        «      sŒ	 | j                   j                  t        |«      «       Œ: t        | j                   «      dk(  rt        d«      ‚y # t        $ r}t        |t        «      r|‚Y d }~Œd }~ww xY w)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%   Úlistr&   Úappendr   r   r   Úlen)r.   rV   r+   r1   s       r2   r3   zPyJWKSet.__init__�   s¬   € Ø!#ˆŒ	áÜÐ FÓGÐGä˜$¤Ô%ÜÐ 7Ó8Ð8ãˆCÜ˜c¤4Ô(àðØ—	‘	× Ñ ¤ s£Õ,ð ô ˆt�y‰y‹>˜QÒÜØgóð ð øô ò Ü˜eÔ%=Ô>Ø�Käûð	ús   Á$BÂ	B6ÂB1Â1B6c                ó<   — | j                  dg «      }t        |«      S )NrV   )r$   rT   )r5   rV   s     r2   r6   zPyJWKSet.from_dict§   s   € à�w‰w�v˜rÓ"ˆÜ˜‹~Ðr7   c                óV   — t        j                  | «      }t        j                  |«      S rH   )r9   r:   rT   r6   )r;   r5   s     r2   r<   zPyJWKSet.from_json¬   s!   € ä�j‰j˜ÓˆÜ×!Ñ! #Ó&Ð&r7   c                óf   — | j                   D ]  }|j                  |k(  sŒ|c S  t        d|› �«      ‚)Nzkeyset has no key for kid: )rV   rD   r)   )r.   rC   r+   s      r2   Ú__getitem__zPyJWKSet.__getitem__±   s6   € Ø—9”9ˆCØ�z‰z˜SÓ Ø’
ð ô Ð4°S°EÐ:Ó;Ð;r7   c                ó,   — t        | j                  «      S rH   )ÚiterrV   r?   s    r2   Ú__iter__zPyJWKSet.__iter__·   s   € Ü�D—I‘I‹Ðr7   N)rV   zlist[JWKDict]rJ   rK   )r5   zdict[str, Any]rJ   rT   )r;   rL   rJ   rT   )rC   rL   rJ   r   )rJ   zIterator[PyJWK])	rM   rN   rO   r3   rP   r6   r<   r]   r`   rR   r7   r2   rT   rT   Œ   s9   „ óð4 òó ðð ò'ó ð'ó<ôr7   rT   c                  ó$   — e Zd Zdd„Zdd„Zdd„Zy)ÚPyJWTSetWithTimestampc                óD   — || _         t        j                  «       | _        y rH   )Újwk_setÚtimeÚ	monotonicÚ	timestamp)r.   rd   s     r2   r3   zPyJWTSetWithTimestamp.__init__¼   s   € ØˆŒÜŸ™Ó)ˆ�r7   c                ó   — | j                   S rH   )rd   r?   s    r2   Úget_jwk_setz!PyJWTSetWithTimestamp.get_jwk_setÀ   s   € Ø�|‰|Ðr7   c                ó   — | j                   S rH   )rg   r?   s    r2   Úget_timestampz#PyJWTSetWithTimestamp.get_timestampÃ   s   € Ø�~‰~Ðr7   N)rd   rT   )rJ   rT   )rJ   Úfloat)rM   rN   rO   r3   ri   rk   rR   r7   r2   rb   rb   »   s   „ ó*óôr7   rb   )Ú
__future__r   r9   re   Úcollections.abcr   Útypingr   Ú
algorithmsr   r   r	   Ú
exceptionsr
   r   r   r   r   Útypesr   r   rT   rb   rR   r7   r2   Ú<module>rs      sK   ðÝ "ã Û Ý $Ý ç QÑ Q÷õ õ ÷v/ñ v/÷r,ñ ,÷^	ò 	r7   