o
    l>j                     @  sn   d dl mZ d dlZd dlmZmZ d dlmZ ddlm	Z	 ddl
mZmZ dd	lmZmZ G d
d dZdS )    )annotationsN)IntEnumunique)Any   )cbor   )Ctap2Info)PinProtocol_PinUvc                   @  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                   @     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   G/home/thesage/.local/lib/python3.10/site-packages/fido2/ctap2/config.pyCMD/   
    r   c                   @  r   )zConfig.PARAMr   r   r      N)r   r   r   NEW_MIN_PIN_LENGTHMIN_PIN_LENGTH_RPIDSFORCE_CHANGE_PINPIN_COMPLEXITY_POLICYr   r   r   r   PARAM6   r   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PinProtocol | Nonepin_uv_tokenbytes | Nonec                 C  sB   |  |js
td|| _|r|rt||nd | _| jjj| _d S )Nz%Authenticator does not support Config)r(   r"   
ValueErrorr)   r   pin_uvauthenticator_config_commands_subcommands)selfr)   r*   r,   r   r   r   __init__A   s   zConfig.__init__c                 C  s   | j d ur|| j vrtd| d| jr8dtd| }|d ur(|t|7 }| jjj}| jj	| jj
|}nd }d }| j||||S )NzConfig command z not supported by Authenticators!   z<B)r1   r.   r/   structpackr   encodeprotocolVERSIONauthenticatetokenr)   config)r2   sub_cmdparamsmsgr*   pin_uv_paramr   r   r   _callR   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   r2   r   r   r   enable_enterprise_attestationa      z$Config.enable_enterprise_attestationc                 C  rB   )zxToggle the alwaysUV setting.

        When true, the Authenticator always requires UV for credential assertion.
        N)r@   r   r   r   rC   r   r   r   toggle_always_uvh   rE   zConfig.toggle_always_uvFmin_pin_length
int | Nonerp_idslist[str] | Noneforce_change_pinpin_complexity_policyc                 C  sn   t jj|i}|dur||t jj< |dur||t jj< |r-| jjjdu r'tdd|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.
        :param pin_complexity_policy: True if the Authenticator should enforce an
            additional PIN complexity policy beyond minPINLength.
        Nz<Authenticator does not support setting PIN complexity policyT)r   r!   r   r   r   r)   r"   rL   r.   r    r@   r   r   )r2   rG   rI   rK   rL   r=   r   r   r   set_min_pin_lengtho   s   zConfig.set_min_pin_length)r"   r
   r#   r$   )NN)r)   r	   r*   r+   r,   r-   )N)r#   rA   )NNFF)
rG   rH   rI   rJ   rK   r$   rL   r$   r#   rA   )r   r   r   __doc__r   r   r   r!   staticmethodr(   r3   r@   rD   rF   rM   r   r   r   r   r   '   s&    


	r   )
__future__r   r4   enumr   r   typingr    r   baser	   r
   pinr   r   r   r   r   r   r   <module>   s   