
    ~h                     ,    d dl mZ 	 ddZddZ	 ddZy)    )TemporaryCredentialc                     fd}fd}fd}fd}| j                  d|       | j                  d|       | j                  d|       | j                  d|       y	)
zRegister temporary credential related hooks to authorization server.

    :param authorization_server: AuthorizationServer instance
    :param cache: Cache instance
    :param key_prefix: key prefix for temporary credential
    c                 j    | d   z   }|| d<   |r|| d<   j                  || d       t        |       S )Noauth_token	client_idoauth_callbackQ timeout)setr   )tokenr   redirect_urikeycache
key_prefixs       c/opt/mcp/mcp-sentiment/venv/lib/python3.12/site-packages/authlib/integrations/flask_oauth1/cache.pycreate_temporary_credentialzHregister_temporary_credential_hooks.<locals>.create_temporary_credential   sG    5//&k&2E"#		#ue	,"5))    c                 R    | sy | z   }j                  |      }|rt        |      S y N)getr   )r   r   valuer   r   s      r   get_temporary_credentialzEregister_temporary_credential_hooks.<locals>.get_temporary_credential   s3    ;&		#&u-- r   c                 8    | r| z   }j                  |       y y r   )delete)r   r   r   r   s     r   delete_temporary_credentialzHregister_temporary_credential_hooks.<locals>.delete_temporary_credential   s!    {*CLL r   c                     | j                         z   }|| d<   |j                         | d<   j                  || d       | S )Noauth_verifieruser_idr	   r
   )get_oauth_tokenget_user_idr   )
credential
grant_userverifierr   r   r   s       r   create_authorization_verifierzJregister_temporary_credential_hooks.<locals>.create_authorization_verifier$   sL    :5577'/
#$ * 6 6 8
9		#z5	1r   r   r   r   r%   N)register_hook)authorization_serverr   r   r   r   r   r%   s    ``    r   #register_temporary_credential_hooksr(      so    *.
 &&%'B &&"$< &&%'B &&')Fr   c                       fd}|S )zCreate an ``exists_nonce`` function that can be used in hooks and
    resource protector.

    :param cache: Cache instance
    :param key_prefix: key prefix for temporary credential
    :param expires: Expire time for nonce
    c                 |     |  d| d| }|r| d| }j                  |      }j                  |d       |S )N-   r
   )hasr   )	nonce	timestampr   r   r   rvr   expiresr   s	         r   exists_noncez.create_exists_nonce_func.<locals>.exists_nonceB   sT    UG1YKq<E;-(CYYs^		#q'	*	r    )r   r   r1   r2   s   ``` r   create_exists_nonce_funcr4   9   s     r   c                 B    t        |||      }| j                  d|       y)zRegister nonce related hooks to authorization server.

    :param authorization_server: AuthorizationServer instance
    :param cache: Cache instance
    :param key_prefix: key prefix for temporary credential
    :param expires: Expire time for nonce
    r2   N)r4   r&   )r'   r   r   r1   r2   s        r   register_nonce_hooksr6   M   s"     ,E:wGL&&~|Dr   N)ztemporary_credential:)znonce:r	   )authlib.oauth1r   r(   r4   r6   r3   r   r   <module>r8      s%    . -D2j* ?DEr   