o
    hu                     @   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   P/var/www/html/openai_agents/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                   @   sP  e Zd ZU dZedddZee ed< dZ	e
d 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_lengthredirect_urisclient_secret_post)noner4   token_endpoint_auth_methodauthorization_coder   )r7   r   grant_typescoderesponse_typesNr   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)   rE   requested_scopesallowed_scopesr   r   r   r   validate_scopeH   s   
z"OAuthClientMetadata.validate_scoperedirect_uric                 C   sF   |d ur|| j vrtd| d|S 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)   rK   r   r   r   validate_redirect_uriR   s   

z)OAuthClientMetadata.validate_redirect_uri)r   r   r   r   r   r3   listr   r    r6   r   r8   r   r:   r   r;   r<   r   r=   r>   r?   r@   rA   rB   r   rC   rD   rJ   rM   r   r   r   r   r/   %   s*   
 
r/   c                   @   sJ   e Zd ZU dZ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S )OAuthClientInformationFullzn
    RFC 7591 OAuth 2.0 Dynamic Client Registration full response
    (client information plus metadata).
    	client_idNclient_secretclient_id_issued_atclient_secret_expires_at)
r   r   r   r   r   r    rQ   rR   r!   rS   r   r   r   r   rO   ^   s   
 rO   c                   @   sx  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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_supportedr9   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)r   r   r   r   r   r    rX   rY   rN   r   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   r   r   r   r   rT   j   s.   
 rT   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_serversNrA   rY   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   rl   rN   rA   rY   r   ro   rp   rq   rr   rs   rt   ru   boolrv   rw   rx   r   r   r   r   rj      s    
 rj   N)typingr   r   pydanticr   r   r   r   r   r	   	Exceptionr$   r.   r/   rO   rT   rj   r   r   r   r   <module>   s    9