o
    iF                     @   s&   d dl mZ G dd dZdd ZdS )    )
json_dumpsc                   @   s4   e Zd ZdZdd ZdddZdddZd	d
 ZdS )KeySetz)This class represents a JSON Web Key Set.c                 C   s
   || _ d S )Nkeys)selfr    r   b/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/authlib/jose/rfc7517/key_set.py__init__   s   
zKeySet.__init__Fc                    s   d fdd| j D iS )z5Represent this key as a dict of the JSON Web Key Set.r   c                    s   g | ]}|j  fi qS r   )as_dict).0k
is_privateparamsr   r   
<listcomp>   s    z"KeySet.as_dict.<locals>.<listcomp>r   )r   r   r   r   r   r   r
   
   s   zKeySet.as_dictc                 K   s   | j |fi |}t|S )z(Represent this key set as a JSON string.)r
   r   )r   r   r   objr   r   r   as_json   s   zKeySet.as_jsonc                    s`    du rt | jdkr| jd S  fdd| jD }|r&tt|fi |}|r,|d S td)zFind the key matches the given kid value.

        :param kid: A string of kid
        :return: Key instance
        :raise: ValueError
        N   r   c                    s   g | ]	}|j  kr|qS r   kid)r   keyr   r   r   r      s    z&KeySet.find_by_kid.<locals>.<listcomp>zKey not found)lenr   list_filter_keys_by_params
ValueError)r   r   r   r   r   r   r   find_by_kid   s   	
zKeySet.find_by_kidN)F)__name__
__module____qualname____doc__r	   r
   r   r   r   r   r   r   r      s    

r   c                 k   sf    | d}| d}| D ]#}|j d}|r|r||krq|j d}|r-|r-||kr-q|V  qd S )Nusealg)gettokens)r   r   _use_algr   designed_usedesigned_algr   r   r   r   (   s   

r   N)authlib.common.encodingr   r   r   r   r   r   r   <module>   s    $