Ë
    ”Â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y)é    Né   )ÚInvalidNonceError)ÚInvalidRequestError)ÚInvalidSignatureError)ÚMissingRequiredParameterError)ÚUnsupportedSignatureMethodError)ÚSIGNATURE_HMAC_SHA1)ÚSIGNATURE_PLAINTEXT)ÚSIGNATURE_RSA_SHA1)Úverify_hmac_sha1)Úverify_plaintext)Úverify_rsa_sha1c                   óN   — 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y)Ú
BaseServeri,  c                 ó"   — || j                   |<   y)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      úZ/var/www/timesheet/venv/lib/python3.12/site-packages/authlib/oauth1/rfc5849/base_server.pyÚregister_signature_methodz$BaseServer.register_signature_method   s   € ð  '-ˆ×Ñ˜dÒ#ó    c                 ó   — |j                   j                  d«      }|j                   j                  d«      }|j                  t        k(  r|s|sy|st	        d«      ‚	 t        |«      }|dk  rt        d«      ‚| j                  r/t        j                  «       |z
  | j                  kD  rt        d«      ‚|st	        d«      ‚| j                  ||«      r
t        «       ‚y# t        t        f$ r}t        d«      |‚d}~ww xY w)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+   sý   € ð
 ×(Ñ(×,Ñ,Ð->Ó?ˆ	Ø×$Ñ$×(Ñ(¨Ó7ˆà×#Ñ#Ô':Ò:ñ ¡UØáÜ/Ð0AÓBÐBð		Rä˜I›ˆIØ˜1Š}Ü)Ð*KÓLÐLà×Ò¤D§I¡I£K°)Ñ$;¸d×>NÑ>NÒ$NÜ)Ð*KÓLÐLñ Ü/°Ó>Ð>à×Ñ˜U GÔ,Ü#Ó%Ð%ð -øô œIÐ&ò 	RÜ%Ð&GÓHÈcÐQûð	Rús   ÁAC ÃC=Ã,C8Ã8C=c                 ó  — |j                   }|st        d«      ‚|| j                  vr
t        «       ‚|j                  st        d«      ‚| j
                  j                  |«      }|s
t        «       ‚ ||«      s
t        «       ‚y)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�   € ð
 ×)Ñ)ˆÙÜ/Ð0HÓIÐIà˜×9Ñ9Ñ9Ü1Ó3Ð3à× Ò Ü/Ð0AÓBÐBà×'Ñ'×+Ñ+¨FÓ3ˆÙÜ1Ó3Ð3á�gŒÜ'Ó)Ð)ð r   c                 ó   — t        «       ‚)zŒGet 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      sR   „ àÐ-Ø˜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>      s5   ðÛ å %Ý 'Ý )Ý 1Ý 3Ý *Ý *Ý )Ý 'Ý 'Ý &÷c$ò c$r   