
    !<i                         d dl 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
 ddlmZ ddlmZ ddlmZ  G d d          ZdS )    N   )InvalidNonceError)InvalidRequestError)InvalidSignatureError)MissingRequiredParameterError)UnsupportedSignatureMethodError)SIGNATURE_HMAC_SHA1)SIGNATURE_PLAINTEXT)SIGNATURE_RSA_SHA1)verify_hmac_sha1)verify_plaintext)verify_rsa_sha1c                   V    e Zd ZeeeeeeiZ	egZ
dZed             Zd Zd Zd Zd ZdS )
BaseServeri,  c                     || j         |<   dS )a  Extend signature method verification.

        :param name: A string to represent signature method.
        :param verify: A function to verify signature.

        The ``verify`` method accept ``OAuth1Request`` as parameter::

            def verify_custom_method(request):
                # verify this request, return True or False
                return True


            Server.register_signature_method("custom-name", verify_custom_method)
        N)SIGNATURE_METHODS)clsnameverifys      /Users/kimhansen/Desktop/03 Workspace/ceo-agents/chl-effectiveness/mcp-servers/whoop/.venv/lib/python3.11/site-packages/authlib/oauth1/rfc5849/base_server.pyregister_signature_methodz$BaseServer.register_signature_method   s      '-d###    c                 .   |j                             d          }|j                             d          }|j        t          k    r|s|sdS |st	          d          	 t          |          }|dk     rt          d          | j        r.t          j                    |z
  | j        k    rt          d          n)# t          t          f$ r}t          d          |d}~ww xY w|st	          d          |                     ||          rt                      dS )zzValidate ``oauth_timestamp`` and ``oauth_nonce`` in HTTP request.

        :param request: OAuth1Request instance
        oauth_timestampoauth_nonceNr   zInvalid "oauth_timestamp" value)oauth_paramsgetsignature_methodr
   r   intr   EXPIRY_TIMEtime
ValueError	TypeErrorexists_noncer   )selfrequest	timestampnonceexcs        r   validate_timestamp_and_noncez'BaseServer.validate_timestamp_and_nonce+   sJ   
 (,,->??	$((77#':::  U  	C/0ABBB		RII1}})*KLLL MDIKK)$;d>N$N$N)*KLLLI& 	R 	R 	R%&GHHcQ	R  	?/>>>UG,, 	&#%%%	& 	&s   AB7 7CCCc                    |j         }|st          d          || j        vrt                      |j        st          d          | j                            |          }|st                       ||          st                      dS )zhValidate ``oauth_signature`` from HTTP request.

        :param request: OAuth1Request instance
        oauth_signature_methodoauth_signatureN)r   r   SUPPORTED_SIGNATURE_METHODSr   	signaturer   r   r   )r%   r&   methodr   s       r   validate_oauth_signaturez#BaseServer.validate_oauth_signatureM   s    
 ) 	J/0HIII9991333  	C/0ABBB'++F33 	41333vg 	*')))	* 	*r   c                     t                      )zGet client instance with the given ``client_id``.

        :param client_id: A string of client_id
        :return: Client instance
        NotImplementedError)r%   	client_ids     r   get_client_by_idzBaseServer.get_client_by_idc   s     "###r   c                     t                      )a	  The nonce value MUST be unique across all requests with the same
        timestamp, client credentials, and token combinations.

        :param nonce: A string value of ``oauth_nonce``
        :param request: OAuth1Request instance
        :return: Boolean
        r3   )r%   r(   r&   s      r   r$   zBaseServer.exists_noncek   s     "###r   N)__name__
__module____qualname__r	   r   r   r   r
   r   r   r.   r    classmethodr   r*   r1   r6   r$    r   r   r   r      s        -O-
 $7"7K- - [-" &  &  &D* * *,$ $ $$ $ $ $ $r   r   )r!   errorsr   r   r   r   r   r/   r	   r
   r   r   r   r   r   r<   r   r   <module>r>      s    % % % % % % ' ' ' ' ' ' ) ) ) ) ) ) 1 1 1 1 1 1 3 3 3 3 3 3 * * * * * * * * * * * * ) ) ) ) ) ) ' ' ' ' ' ' ' ' ' ' ' ' & & & & & &c$ c$ c$ c$ c$ c$ c$ c$ c$ c$r   