
    i[f                     .    d dl mZ 	 d	dZd
dZ	 d
dZdS )    )TemporaryCredentialtemporary_credential:c                     fd}fd}fd}fd}|                      d|           |                      d|           |                      d|           |                      d|           d	S )
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                     | d         z   }|| d<   |r|| d<                        || d           t          |           S )Noauth_token	client_idoauth_callbackQ timeout)setr   )tokenr   redirect_urikeycache
key_prefixs       [/var/www/piapp/venv/lib/python3.11/site-packages/authlib/integrations/flask_oauth1/cache.pycreate_temporary_credentialzHregister_temporary_credential_hooks.<locals>.create_temporary_credential   sU    5//&k 	3&2E"#		#ue	,,,"5)))    c                 f    | sd S | z   }                     |          }|rt          |          S d S N)getr   )r   r   valuer   r   s      r   get_temporary_credentialzEregister_temporary_credential_hooks.<locals>.get_temporary_credential   sI     	4;&		# 	.&u---	. 	.r   c                 D    | r| z   }                     |           d S d S r   )delete)r   r   r   r   s     r   delete_temporary_credentialzHregister_temporary_credential_hooks.<locals>.delete_temporary_credential   s7     	{*CLL	 	r   c                     |                                  z   }|| d<   |                                | d<                       || 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#   sX    :55777'/
#$ * 6 6 8 8
9		#z5	111r   r   r   r   r&   N)register_hook)authorization_serverr   r   r   r   r   r&   s    ``    r   #register_temporary_credential_hooksr)      s   * * * * * *. . . . . .     
      &&%'BD D D&&"$<> > >&&%'BD D D&&')FH H H H Hr   nonce: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| }                     |          }                    |d           |S )N-   r   )hasr   )	nonce	timestampr   r   r   rvr   expiresr   s	         r   exists_noncez.create_exists_nonce_func.<locals>.exists_nonce<   sj    <U<<Y<<<< 	)((;((CYYs^^		#q'	***	r    )r   r   r3   r4   s   ``` r   create_exists_nonce_funcr6   4   s0           r   c                 T    t          |||          }|                     d|           dS )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
    r4   N)r6   r'   )r(   r   r   r3   r4   s        r   register_nonce_hooksr8   F   s1     ,E:wGGL&&~|DDDDDr   N)r   )r*   r
   )authlib.oauth1r   r)   r6   r8   r5   r   r   <module>r:      su    . . . . . . 1H-H -H -H -H`   & CH
E 
E 
E 
E 
E 
Er   