o
    *i.                     @   s   d dl mZmZ d dlmZmZmZmZmZ G dd deZ	G dd de
ZG dd de
ZG d	d
 d
eZG dd deZG dd deZG dd deZdS )    )AnyLiteral)
AnyHttpUrlAnyUrl	BaseModelFieldfield_validatorc                   @   s   e Zd ZU dZeed< dZed ed< dZe	dB ed< dZ
edB ed< dZedB ed< edd	d
ededB dedB fddZdS )
OAuthTokenzG
    See https://datatracker.ietf.org/doc/html/rfc6749#section-5.1
    access_tokenBearer
token_typeN
expires_inscoperefresh_tokenbefore)modevreturnc                 C   s   t |tr	| S |S N)
isinstancestrtitle)clsr    r   L/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/mcp/shared/auth.pynormalize_token_type   s   
zOAuthToken.normalize_token_type)__name__
__module____qualname____doc__r   __annotations__r   r   r   intr   r   r   classmethodr   r   r   r   r   r	      s   
 
"r	   c                   @      e Zd ZdefddZdS )InvalidScopeErrormessagec                 C   
   || _ d S r   r%   selfr%   r   r   r   __init__      
zInvalidScopeError.__init__Nr   r   r   r   r*   r   r   r   r   r$          r$   c                   @   r#   )InvalidRedirectUriErrorr%   c                 C   r&   r   r'   r(   r   r   r   r*   !   r+   z InvalidRedirectUriError.__init__Nr,   r   r   r   r   r.       r-   r.   c                   @   sX  e Zd ZU dZedddZee dB ed< dZ	e
d dB ed< d	d
gZee
d eB  ed< dgZee ed< dZedB ed< dZedB ed< dZedB ed< dZedB ed< dZee dB ed< dZedB ed< dZedB ed< dZedB ed< dZedB ed< dZedB ed< dZedB ed< dedB dee dB fddZdedB defdd ZdS )!OAuthClientMetadataz
    RFC 7591 OAuth 2.0 Dynamic Client Registration metadata.
    See https://datatracker.ietf.org/doc/html/rfc7591#section-2
    for the full specification.
    .   
min_lengthNredirect_uris)noneclient_secret_postclient_secret_basicprivate_key_jwttoken_endpoint_auth_methodauthorization_coder   )r9   r   z+urn:ietf:params:oauth:grant-type:jwt-bearergrant_typescoderesponse_typesr   client_name
client_urilogo_uricontactstos_uri
policy_urijwks_urijwkssoftware_idsoftware_versionrequested_scoper   c                 C   sT   |d u rd S | d}| jd u rg n| j d}|D ]}||vr'td| q|S )N z%Client was not registered with scope )splitr   r$   )r)   rG   requested_scopesallowed_scopesr   r   r   r   validate_scopeJ   s   
z"OAuthClientMetadata.validate_scoperedirect_uric                 C   sZ   |d ur| j d u s|| j vrtd| d|S | j d ur)t| j dkr)| j d S td)NzRedirect URI 'z' not registered for clientr0   r   zGredirect_uri must be specified when client has multiple registered URIs)r3   r.   len)r)   rM   r   r   r   validate_redirect_uriT   s   
z)OAuthClientMetadata.validate_redirect_uri)r   r   r   r   r   r3   listr   r    r8   r   r:   r   r<   r   r=   r>   r   r?   r@   rA   rB   rC   rD   r   rE   rF   rL   rO   r   r   r   r   r/   %   s6   
 


r/   c                   @   sR   e Zd ZU dZdZedB ed< dZedB ed< dZe	dB ed< dZ
e	dB ed< dS )OAuthClientInformationFullzn
    RFC 7591 OAuth 2.0 Dynamic Client Registration full response
    (client information plus metadata).
    N	client_idclient_secretclient_id_issued_atclient_secret_expires_at)r   r   r   r   rR   r   r    rS   rT   r!   rU   r   r   r   r   rQ   `   s   
 rQ   c                   @   s  e Zd ZU dZeed< eed< eed< dZedB ed< dZee	 dB ed< dgZ
ee	 ed	< dZee	 dB ed
< dZee	 dB ed< dZee	 dB ed< dZee	 dB ed< dZedB ed< dZee	 dB ed< dZedB ed< dZedB ed< dZedB ed< dZee	 dB ed< dZee	 dB ed< dZedB ed< dZee	 dB ed< dZee	 dB ed< dZee	 dB ed< dZedB ed< dS )OAuthMetadataz{
    RFC 8414 OAuth 2.0 Authorization Server Metadata.
    See https://datatracker.ietf.org/doc/html/rfc8414#section-2
    issuerauthorization_endpointtoken_endpointNregistration_endpointscopes_supportedr;   response_types_supportedresponse_modes_supportedgrant_types_supported%token_endpoint_auth_methods_supported0token_endpoint_auth_signing_alg_values_supportedservice_documentationui_locales_supportedop_policy_uri
op_tos_urirevocation_endpoint*revocation_endpoint_auth_methods_supported5revocation_endpoint_auth_signing_alg_values_supportedintrospection_endpoint-introspection_endpoint_auth_methods_supported8introspection_endpoint_auth_signing_alg_values_supported code_challenge_methods_supported%client_id_metadata_document_supported)r   r   r   r   r   r    rZ   r[   rP   r   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   boolr   r   r   r   rV   l   s0   
 rV   c                   @   s  e Zd ZU dZeed< edddZee ed< dZ	edB ed< dZ
ee dB ed	< ed
gdZee dB ed< dZee dB ed< dZedB ed< dZedB ed< dZedB ed< dZedB ed< dZedB ed< dZee dB ed< dZee dB ed< dZedB ed< dS )ProtectedResourceMetadatazy
    RFC 9728 OAuth 2.0 Protected Resource Metadata.
    See https://datatracker.ietf.org/doc/html/rfc9728#section-2
    resource.r0   r1   authorization_serversNrC   r[   header)defaultbearer_methods_supported%resource_signing_alg_values_supportedresource_nameresource_documentationresource_policy_uriresource_tos_uri*tls_client_certificate_bound_access_tokens%authorization_details_types_supported!dpop_signing_alg_values_supported!dpop_bound_access_tokens_required)r   r   r   r   r   r    r   rp   rP   rC   r[   r   rs   rt   ru   rv   rw   rx   ry   rm   rz   r{   r|   r   r   r   r   rn      s    
 rn   N)typingr   r   pydanticr   r   r   r   r   r	   	Exceptionr$   r.   r/   rQ   rV   rn   r   r   r   r   <module>   s    ;