
    Dj                    |    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          ZdS )    )annotationsN)IntEnumunique)Any   )cbor   )Ctap2Info)PinProtocol_PinUvc                      e Zd ZdZe G d de                      Ze G d de                      Zedd
            Z		 	 d d!dZ
d"dZd#dZd#dZ	 	 	 	 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 )
Config.CMDr	   r         N)__name__
__module____qualname__ENABLE_ENTERPRISE_ATTTOGGLE_ALWAYS_UVSET_MIN_PIN_LENGTHVENDOR_PROTOTYPE     M/home/thesage/.hermes/venv/lib/python3.11/site-packages/fido2/ctap2/config.pyCMDr   /   s(         $!r   r   c                      e Zd ZdZdZdZdZdS )Config.PARAMr	   r   r      N)r   r   r   NEW_MIN_PIN_LENGTHMIN_PIN_LENGTH_RPIDSFORCE_CHANGE_PINPIN_COMPLEXITY_POLICYr   r   r   PARAMr    6   s(        !# $r   r&   infor   returnboolc                :    | j                             d          du S )N	authnrCfgT)optionsget)r'   s    r   is_supportedzConfig.is_supported=   s    |,,44r   Nctapr
   pin_uv_protocolPinProtocol | Nonepin_uv_tokenbytes | Nonec                    |                      |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/   r0   r2   s       r   __init__zConfig.__init__A   su       ++ 	FDEEE	 #/F?L111 	
 !INHr   c                r   | j         || j         vrt          d| d          | j        rmdt          j        d|          z   }||t          j        |          z  }| j        j        j        }| j        j        	                    | j        j
        |          }nd }d }| j                            ||||          S )NzConfig command z not supported by Authenticators!   z<B)r8   r5   r6   structpackr   encodeprotocolVERSIONauthenticatetokenr/   config)r9   sub_cmdparamsmsgr0   pin_uv_params         r   _callzConfig._callR   s    (WD<M-M-MWwWWWXXX; 	 (6;tW+E+EEC!t{6***"k2:O;/<<T[=NPSTTLL"OLy,OOOr   Nonec                N    |                      t          j        j                   dS )z^Enables Enterprise Attestation.

        If already enabled, this command is ignored.
        N)rH   r   r   r   r9   s    r   enable_enterprise_attestationz$Config.enable_enterprise_attestationa   s!    
 	

6:344444r   c                N    |                      t          j        j                   dS )zxToggle the alwaysUV setting.

        When true, the Authenticator always requires UV for credential assertion.
        N)rH   r   r   r   rK   s    r   toggle_always_uvzConfig.toggle_always_uvh   s!    
 	

6:./////r   Fmin_pin_length
int | Nonerp_idslist[str] | Noneforce_change_pinpin_complexity_policyc                :   t           j        j        |i}|||t           j        j        <   |||t           j        j        <   |r4| j        j        j        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'   rT   r5   r%   rH   r   r   )r9   rO   rQ   rS   rT   rE   s         r   set_min_pin_lengthzConfig.set_min_pin_lengtho   s    " #),"?AQ!R%6DF6<238>F6<45  	>y~3; R   :>F6<56

6:0&99999r   )r'   r   r(   r)   )NN)r/   r
   r0   r1   r2   r3   )N)r(   rI   )NNFF)
rO   rP   rQ   rR   rS   r)   rT   r)   r(   rI   )r   r   r   __doc__r   r   r   r&   staticmethodr.   r:   rH   rL   rN   rV   r   r   r   r   r   '   s7                  g     V  % % % % % % % V% 5 5 5 \5 /3%)	I I I I I"P P P P5 5 5 50 0 0 0 &*#'!&&+: : : : : : :r   r   )
__future__r   r<   enumr   r   typingr    r   baser
   r   pinr   r   r   r   r   r   <module>r_      s   8 # " " " " "                                      $ $ $ $ $ $ $ $d: d: d: d: d: d: d: d: d: d:r   