Ë
    lŸKj<  ã                   óz   — d dl mZ d dl mZ d dlmZ d dlmZ d dlmZ ddl	m
Z
 dd	lmZ dd
lmZ  G d„ de
«      Zy)é    )ÚExpiredTokenError)ÚInvalidClaimError)ÚContinueIteration)Údefault_json_headers)ÚInvalidTokenErroré   )ÚIntrospectionEndpointé   )ÚJWTAccessTokenClaims)ÚJWTBearerTokenValidatorc                   óV   ‡ — e Zd ZdZdZdˆ fd„	Zd„ Zd„ Zdefd„Z	d„ Z
d	ed
efd„Zˆ xZS )ÚJWTIntrospectionEndpointað  JWTIntrospectionEndpoint inherits from :ref:`specs/rfc7662`
    :class:`~authlib.oauth2.rfc7662.IntrospectionEndpoint` and implements the machinery
    to automatically process the JWT access tokens.

    :param issuer: The issuer identifier for which tokens will be introspected.

    :param \\*\\*kwargs: Other parameters are inherited from
        :class:`~authlib.oauth2.rfc7662.introspection.IntrospectionEndpoint`.

    ::

        class MyJWTAccessTokenIntrospectionEndpoint(JWTIntrospectionEndpoint):
            def get_jwks(self): ...

            def get_username(self, user_id): ...


        # endpoint dedicated to JWT access token introspection
        authorization_server.register_endpoint(
            MyJWTAccessTokenIntrospectionEndpoint(
                issuer="https://authorization-server.example.org",
            )
        )

        # another endpoint dedicated to refresh token introspection
        authorization_server.register_endpoint(MyRefreshTokenIntrospectionEndpoint)

    Úintrospectionc                 ó6   •— t        ‰|   |d|i|¤Ž || _        y )NÚserver)ÚsuperÚ__init__Úissuer)Úselfr   r   ÚargsÚkwargsÚ	__class__s        €úu/Users/ahmed/devFolder/Ultron/claude-voice/.venv/lib/python3.12/site-packages/authlib/oauth2/rfc9068/introspection.pyr   z!JWTIntrospectionEndpoint.__init__.   s!   ø€ Ü‰Ñ˜$Ð8 vÐ8°Ò8Øˆó    c                 ó|   — | j                  |«      }| j                  ||«      }| j                  |«      }d|t        fS )Ú éÈ   )Úauthenticate_endpoint_clientÚauthenticate_tokenÚcreate_introspection_payloadr   )r   ÚrequestÚclientÚtokenÚbodys        r   Úcreate_endpoint_responsez1JWTIntrospectionEndpoint.create_endpoint_response2   sH   € ð ×2Ñ2°7Ó;ˆð ×'Ñ'¨°Ó8ˆð ×0Ñ0°Ó7ˆØDÔ.Ð.Ð.r   c                 ól  — | j                  ||«       |j                  j                  d«      dvr
t        «       ‚t	        | j
                  d¬«      }| j                  |_        	 |j                  |j                  d   «      }|r| j                  |||«      r|S yy# t        $ r}t        «       |‚d}~ww xY w)r   Útoken_type_hint)Úaccess_tokenNN)r   Úresource_serverr#   )
Úcheck_paramsÚformÚgetr   r   r   Úget_jwksr   r   Úcheck_permission)r   r!   r"   Ú	validatorr#   Úexcs         r   r   z+JWTIntrospectionEndpoint.authenticate_token?   s±   € à×Ñ˜' 6Ô*ð <‰<×ÑÐ-Ó.Ð6LÑLÜ#Ó%Ð%ä+°4·;±;ÐPTÔUˆ	Ø!Ÿ]™]ˆ	Ôð	/Ø×0Ñ0°·±¸gÑ1FÓGˆEñ T×*Ñ*¨5°&¸'ÔBØˆLð Cˆ5øô !ò 	/Ü#Ó%¨3Ð.ûð	/ús   Á#B Â	B3Â#B.Â.B3r#   c           
      ó4  — |sddiS 	 |j                  «        dd|d   |d   |d   |d	   |d   |d
   |d   dœ	}| j                  |d   «      x}r||d<   |S # t        $ r ddicY S t        $ r*}|j                  dk(  rt	        «       |‚t        «       |‚d }~ww xY w)NÚactiveFÚissTÚBearerÚ	client_idÚscopeÚsubÚaudÚexpÚiat)	r2   Ú
token_typer5   r6   r7   r8   r3   r9   r:   Úusername)Úvalidater   r   Úclaimr   r   Úget_username)r   r#   r0   Úpayloadr<   s        r   r    z5JWTIntrospectionEndpoint.create_introspection_payloadS   sÒ   € ÙØ˜eÐ$Ð$ð	/ØN‰NÔð Ø"Ø˜{Ñ+Ø˜7‘^Ø˜‘<Ø˜‘<Ø˜‘<Ø˜‘<Ø˜‘<ñ

ˆð ×(Ñ(¨¨u©Ó6Ð6ˆ8Ð6Ø"*ˆGJÑàˆøô- !ò 	%Ø˜eÐ$Ò$Ü ò 	/Øy‰y˜EÒ!Ü'Ó)¨sÐ2Ü#Ó%¨3Ð.ûð	/ús   ˆA ÁBÁ%BÁ-%BÂBc                 ó   — t        «       ‚)zÕReturn the JWKs that will be used to check the JWT access token signature.
        Developers MUST re-implement this method::

            def get_jwks(self):
                return load_jwks("jwks.json")
        )ÚNotImplementedError)r   s    r   r-   z!JWTIntrospectionEndpoint.get_jwksq   s   € ô "Ó#Ð#r   Úuser_idÚreturnc                  ó   — y)zÁReturns an username from a user ID.
        Developers MAY re-implement this method::

            def get_username(self, user_id):
                return User.get(id=user_id).username
        N© )r   rC   s     r   r?   z%JWTIntrospectionEndpoint.get_usernamez   s   € ð r   )N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚENDPOINT_NAMEr   r%   r   r   r    r-   Ústrr?   Ú__classcell__)r   s   @r   r   r      sC   ø„ ñð< $€Mõò/òð(Ð2Fó ò<$ð Cð ¨C÷ r   r   N)Újoserfc.errorsr   r   Úauthlib.common.errorsr   Úauthlib.constsr   Úauthlib.oauth2.rfc6750.errorsr   Úrfc7662r	   Úclaimsr   Útoken_validatorr   r   rF   r   r   Ú<module>rU      s,   ðÝ ,Ý ,å 3Ý /Ý ;å +Ý (Ý 4ôtÐ4õ tr   