o
    sh4                     @  sz   d dl mZ ddlmZ ddlmZmZ ddlmZm	Z	 d dl
mZmZmZmZ d dlmZmZ d d	lZG d
d dZd	S )    )annotations   )cbor   )Ctap2Info)PinProtocol_PinUv)OptionalListDictAny)IntEnumuniqueNc                   @  s   e Zd ZdZeG dd deZeG dd deZed$d
dZ			d%d&ddZ
d'ddZd(ddZd(ddZ			d)d*d"d#ZdS )+ConfigzImplementation of the CTAP2.1 Authenticator Config API.

    :param ctap: An instance of a CTAP2 object.
    :param pin_uv_protocol: An instance of a PinUvAuthProtocol.
    :param pin_uv_token: A valid PIN/UV Auth Token for the current CTAP session.
    c                   @  s   e Zd ZdZdZdZdZdS )z
Config.CMDr   r         N)__name__
__module____qualname__ENABLE_ENTERPRISE_ATTTOGGLE_ALWAYS_UVSET_MIN_PIN_LENGTHVENDOR_PROTOTYPE r   r   M/var/www/html/env_mimamsha/lib/python3.10/site-packages/fido2/ctap2/config.pyCMD/   s
    r   c                   @  s   e Zd ZdZdZdZdS )zConfig.PARAMr   r   r   N)r   r   r   NEW_MIN_PIN_LENGTHMIN_PIN_LENGTH_RPIDSFORCE_CHANGE_PINr   r   r   r   PARAM6   s    r    infor   returnboolc                 C  s   | j ddu S )N	authnrCfgT)optionsget)r!   r   r   r   is_supported<   s   zConfig.is_supportedNctapr   pin_uv_protocolOptional[PinProtocol]pin_uv_tokenOptional[bytes]c                 C  s<   |  |js
td|| _|r|rt||| _d S d | _d S )Nz%Authenticator does not support Config)r'   r!   
ValueErrorr(   r	   pin_uv)selfr(   r)   r+   r   r   r   __init__@   s   
zConfig.__init__c                 C  sf   | j r&dtd| }|d ur|t|7 }| j jj}| j j| j j|}nd }d }| j	
||||S )Ns!   z<B)r.   structpackr   encodeprotocolVERSIONauthenticatetokenr(   config)r/   sub_cmdparamsmsgr)   pin_uv_paramr   r   r   _callP   s   
zConfig._callNonec                 C     |  tjj dS )z^Enables Enterprise Attestation.

        If already enabled, this command is ignored.
        N)r=   r   r   r   r/   r   r   r   enable_enterprise_attestation\      z$Config.enable_enterprise_attestationc                 C  r?   )zxToggle the alwaysUV setting.

        When true, the Authenticator always requires UV for credential assertion.
        N)r=   r   r   r   r@   r   r   r   toggle_always_uvc   rB   zConfig.toggle_always_uvFmin_pin_lengthOptional[int]rp_idsOptional[List[str]]force_change_pinc                 C  sH   t jj|i}|dur||t jj< |dur||t jj< | t jj| dS )a  Set the minimum PIN length allowed when setting/changing the PIN.

        :param min_pin_length: The minimum PIN length the Authenticator should allow.
        :param rp_ids: A list of RP IDs which should be allowed to get the current
            minimum PIN length.
        :param force_change_pin: True if the Authenticator should enforce changing the
            PIN before the next use.
        N)r   r    r   r   r   r=   r   r   )r/   rD   rF   rH   r:   r   r   r   set_min_pin_lengthj   s   zConfig.set_min_pin_length)r!   r   r"   r#   )NN)r(   r   r)   r*   r+   r,   )N)r"   r>   )NNF)rD   rE   rF   rG   rH   r#   r"   r>   )r   r   r   __doc__r   r   r   r    staticmethodr'   r0   r=   rA   rC   rI   r   r   r   r   r   '   s$    


	r   )
__future__r    r   baser   r   pinr   r	   typingr
   r   r   r   enumr   r   r1   r   r   r   r   r   <module>   s   