
     f                         d dl Z d dlZd dlmZ d dlmZ d dlmZ  G d dee          Z G d dee          Z	 G d	 d
          Z
 G d d          Zd Zd ZdS )    N)urlsafe_b64decode)urlsafe_b64encode)Enumc                   0    e Zd ZU dZdZeed<   dZeed<   dS )Protocolz/Protocol to communicate with the authenticator.ctap2CTAP2z	ctap1/u2fU2FN)__name__
__module____qualname____doc__r	   str__annotations__r
        r/var/www/api.educacionweb.es/myenv/lib/python3.11/site-packages/selenium/webdriver/common/virtual_authenticator.pyr   r      s8         99E3Cr   r   c                   L    e Zd ZU dZdZeed<   dZeed<   dZeed<   dZ	eed	<   d
S )	Transportz7Transport method to communicate with the authenticator.bleBLEusbUSBnfcNFCinternalINTERNALN)
r   r   r   r   r   r   r   r   r   r   r   r   r   r   r       sX         AACCCHcr   r   c                       e Zd ZeZeZej        ej        ddddfdedededededed	d
fdZ	d	e
j        ee
j        eef         f         fdZd
S )VirtualAuthenticatorOptionsFTprotocol	transporthas_resident_keyhas_user_verificationis_user_consentingis_user_verifiedreturnNc                 Z    || _         || _        || _        || _        || _        || _        dS )zMConstructor.

        Initialize VirtualAuthenticatorOptions object.
        Nr    r!   r"   r#   r$   r%   )selfr    r!   r"   r#   r$   r%   s          r   __init__z$VirtualAuthenticatorOptions.__init__/   s8     &'&6+@"(:&6r   c                 P    | j         | j        | j        | j        | j        | j        dS )N)r    r!   hasResidentKeyhasUserVerificationisUserConsentingisUserVerifiedr(   r)   s    r   to_dictz#VirtualAuthenticatorOptions.to_dictD   s3    "3#'#= $ 7"3
 
 	
r   )r   r   r   r   r   r	   r   r   boolr*   typingDictUnionr1   r   r   r   r   r   )   s         HI !"!&&+#'!&7 77 7 	7
  $7 !7 7 
7 7 7 7*
S&,sDy*A%AB 
 
 
 
 
 
r   r   c                      e Zd Zdedededej        e         dedefdZ	e
defd	            Ze
defd
            Ze
defd            Ze
dej        e         fd            Ze
defd            Ze
defd            Zedededededd f
d            Zedededej        e         dededd fd            Zdej        eej        f         fdZedej        eej        f         dd fd            ZdefdZdS )
Credentialcredential_idis_resident_credentialrp_iduser_handleprivate_key
sign_countc                 Z    || _         || _        || _        || _        || _        || _        dS )ah  Constructor. A credential stored in a virtual authenticator.
        https://w3c.github.io/webauthn/#credential-parameters.

        :Args:
            - credential_id (bytes): Unique base64 encoded string.
            is_resident_credential (bool): Whether the credential is client-side discoverable.
            rp_id (str): Relying party identifier.
            user_handle (bytes): userHandle associated to the credential. Must be Base64 encoded string. Can be None.
            private_key (bytes): Base64 encoded PKCS#8 private key.
            sign_count (int): intital value for a signature counter.
        N)_id_is_resident_credential_rp_id_user_handle_private_key_sign_count)r)   r8   r9   r:   r;   r<   r=   s          r   r*   zCredential.__init__P   s8    ( !'=$''%r   r&   c                 N    t          | j                                                  S N)r   r?   decoder0   s    r   idzCredential.idk   s     **11333r   c                     | j         S rF   )r@   r0   s    r   r9   z!Credential.is_resident_credentialo   s    ++r   c                     | j         S rF   )rA   r0   s    r   r:   zCredential.rp_ids   s
    {r   c                 `    | j         r&t          | j                                                   S d S rF   )rB   r   rG   r0   s    r   r;   zCredential.user_handlew   s0     	A$T%677>>@@@tr   c                 N    t          | j                                                  S rF   )r   rC   rG   r0   s    r   r<   zCredential.private_key}   s     !233::<<<r   c                     | j         S rF   )rD   r0   s    r   r=   zCredential.sign_count   s    r   rH   c                 "     | |d|d||          S )au  Creates a non-resident (i.e. stateless) credential.

        :Args:
          - id (bytes): Unique base64 encoded string.
          - rp_id (str): Relying party identifier.
          - private_key (bytes): Base64 encoded PKCS
          - sign_count (int): intital value for a signature counter.

        :Returns:
          - Credential: A non-resident credential.
        FNr   )clsrH   r:   r<   r=   s        r   create_non_resident_credentialz)Credential.create_non_resident_credential   s     s2ueT;
CCCr   c                 "     | |d||||          S )a  Creates a resident (i.e. stateful) credential.

        :Args:
          - id (bytes): Unique base64 encoded string.
          - rp_id (str): Relying party identifier.
          - user_handle (bytes): userHandle associated to the credential. Must be Base64 encoded string.
          - private_key (bytes): Base64 encoded PKCS
          - sign_count (int): intital value for a signature counter.

        :returns:
          - Credential: A resident credential.
        Tr   )rO   rH   r:   r;   r<   r=   s         r   create_resident_credentialz%Credential.create_resident_credential   s      s2tUKjIIIr   c                 j    | j         | j        | j        | j        | j        d}| j        r
| j        |d<   |S )N)credentialIdisResidentCredentialrpId
privateKey	signCount
userHandle)rH   r@   r:   r<   r=   r;   )r)   credential_datas     r   r1   zCredential.to_dict   sI     G$($@J*
 
  	=,0,<OL)r   datac                 b   t          |d          d          }t          |d                   }|                    dd           }t          |d          d          }t          |d                   }|                    dd           rt          |d          d          nd } | ||||||          S )NrT   z==rU   rV   rW   rX   rY   )r   r2   getint)rO   r[   r?   r9   r:   r<   r=   r;   s           r   	from_dictzCredential.from_dict   s    4#7 ; ; ;<<!%d+A&B!C!C&&'4+=(A(A(ABBk*++
FJhh|]aFbFbl'4+=(A(A(ABBBhls3.{KQ[\\\r   c                 h    d| j          d| j         d| j         d| j         d| j         d| j         dS )NzCredential(id=z, is_resident_credential=z, rp_id=z,            user_handle=z, private_key=z, sign_count=))rH   r9   r:   r;   r<   r=   r0   s    r   __str__zCredential.__str__   s}    k k k$B] k kgkgq k k)k k9=9Ik kX\Xgk k k 	kr   N)r   r   r   bytesr2   r   r3   Optionalr^   r*   propertyrH   r9   r:   r;   r<   r=   classmethodrP   rR   r4   Anyr1   r_   rb   r   r   r   r7   r7   O   s       && !%& 	&
 _U+& & & & & &6 4C 4 4 4 X4 , , , , X, s    X V_S1    X
 =S = = = X=  C       X  D Dc DPU Dcf Dkw D D D [D JJ"J171GJV[JilJ	J J J [J"S&*_5     ]V[fj9 ]l ] ] ] []k k k k k k kr   r7   c                 F     t          j                    fd            }|S )zKA decorator to ensure that the client used is a chromium based
    browser.c                 r    | j         d                                         dvs
J d             | g|R i |S )NbrowserName)firefoxsafariz4This only currently works in Chromium based browsers)capslowerr)   argskwargsfuncs      r   wrapperz0required_chromium_based_browser.<locals>.wrapper   sd    y'--// 8
 
 
 
 B
 
 
 tD*4***6***r   )	functoolswrapsrr   rs   s   ` r   required_chromium_based_browserrw      s:     _T+ + + + + Nr   c                 `     t          j                   t           fd                        }|S )zSA decorator to ensure that the function is called with a virtual
    authenticator.c                 H    | j         st          d           | g|R i |S )Nz9This function requires a virtual authenticator to be set.)virtual_authenticator_id
ValueErrorro   s      r   rs   z/required_virtual_authenticator.<locals>.wrapper   s@     , 	ZXYYYtD*4***6***r   )rt   ru   rw   rv   s   ` r   required_virtual_authenticatorr|      sE     _T$+ + + + %$ +
 Nr   )rt   r3   base64r   r   enumr   r   r   r   r   r7   rw   r|   r   r   r   <module>r      s4  $      $ $ $ $ $ $ $ $ $ $ $ $          sD       T   #
 #
 #
 #
 #
 #
 #
 #
Lrk rk rk rk rk rk rk rkj      r   