o
    ҷh$                     @  s   d dl mZ ddlmZmZ d dlmZ d dlZd dlZG dd de	Z
G dd	 d	ejZG d
d dejZeG dd dZeG dd dZd0ddZd0ddZd1ddZd2ddZd3ddZd4d#d$Zd5d&d'Zd6d(d)Zd2d*d+Zd7d.d/ZdS )8    )annotations   )event_classT_JSON_DICT)	dataclassNc                      s4   e Zd Zd
ddZedddZ fdd	Z  ZS )AuthenticatorIdreturnstrc                 C  s   | S N selfr   r   c/var/www/html/venv/lib/python3.10/site-packages/selenium/webdriver/common/devtools/v85/web_authn.pyto_json   s   zAuthenticatorId.to_jsonjsonc                 C     | |S r
   r   clsr   r   r   r   	from_json      zAuthenticatorId.from_jsonc                   s   d t  S )NzAuthenticatorId({}))formatsuper__repr__r   	__class__r   r   r      s   zAuthenticatorId.__repr__)r   r	   )r   r	   r   r   )__name__
__module____qualname__r   classmethodr   r   __classcell__r   r   r   r   r      s
    
r   c                   @  s(   e Zd ZdZdZdd Zedd ZdS )AuthenticatorProtocolu2fctap2c                 C     | j S r
   valuer   r   r   r   r         zAuthenticatorProtocol.to_jsonc                 C  r   r
   r   r   r   r   r   r       r   zAuthenticatorProtocol.from_jsonN)r   r   r   U2FCTAP2r   r   r   r   r   r   r   r       s    r    c                   @  s4   e Zd ZdZdZdZdZdZdd Ze	dd	 Z
d
S )AuthenticatorTransportusbnfcblecableinternalc                 C  r#   r
   r$   r   r   r   r   r   ,   r&   zAuthenticatorTransport.to_jsonc                 C  r   r
   r   r   r   r   r   r   /   r   z AuthenticatorTransport.from_jsonN)r   r   r   USBNFCBLECABLEINTERNALr   r   r   r   r   r   r   r)   %   s    r)   c                   @  sb   e Zd ZU ded< ded< dZded< dZded< dZded	< dZded
< dd Ze	dd Z
dS )VirtualAuthenticatorOptionsr    protocolr)   	transportNztyping.Optional[bool]has_resident_keyhas_user_verificationautomatic_presence_simulationis_user_verifiedc                 C  sv   t  }| j |d< | j |d< | jd ur| j|d< | jd ur%| j|d< | jd ur/| j|d< | jd ur9| j|d< |S )Nr5   r6   hasResidentKeyhasUserVerificationautomaticPresenceSimulationisUserVerified)dictr5   r   r6   r7   r8   r9   r:   r   r   r   r   r   r   H   s   







z#VirtualAuthenticatorOptions.to_jsonc              	   C  s|   | t |d t|d d|v rt|d nd d|v r"t|d nd d|v r-t|d nd d|v r:t|d dS d dS )Nr5   r6   r;   r<   r=   r>   )r5   r6   r7   r8   r9   r:   )r    r   r)   boolr   r   r   r   r   V   s   z%VirtualAuthenticatorOptions.from_json)r   r   r   __annotations__r7   r8   r9   r:   r   r   r   r   r   r   r   r4   4   s   
 r4   c                   @  sZ   e Zd ZU ded< ded< ded< ded< dZd	ed
< dZd	ed< dd Zedd ZdS )
Credentialr	   credential_idrA   is_resident_credentialprivate_keyint
sign_countNztyping.Optional[str]rp_iduser_handlec                 C  sZ   t  }| j|d< | j|d< | j|d< | j|d< | jd ur!| j|d< | jd ur+| j|d< |S )NcredentialIdisResidentCredential
privateKey	signCountrpId
userHandle)r?   rD   rE   rF   rH   rI   rJ   r@   r   r   r   r   x   s   







zCredential.to_jsonc              	   C  s`   | t |d t|d t |d t|d d|v rt |d nd d|v r,t |d dS d dS )NrK   rL   rM   rN   rO   rP   )rD   rE   rF   rH   rI   rJ   )r	   rA   rG   r   r   r   r   r      s   



zCredential.from_json)	r   r   r   rB   rI   rJ   r   r   r   r   r   r   r   rC   b   s   
 rC   r   0typing.Generator[T_JSON_DICT, T_JSON_DICT, None]c                  c      ddi} | V }dS )z~
    Enable the WebAuthn domain and start intercepting credential storage and
    retrieval with a virtual authenticator.
    methodzWebAuthn.enableNr   cmd_dictr   r   r   r   enable   s   
rV   c                  c  rR   )z&
    Disable the WebAuthn domain.
    rS   zWebAuthn.disableNr   rT   r   r   r   disable   s   
rW   options;typing.Generator[T_JSON_DICT, T_JSON_DICT, AuthenticatorId]c                 c  s2    t  }|  |d< d|d}|V }t|d S )zW
    Creates and adds a virtual authenticator.

    :param options:
    :returns: 
    rX   z WebAuthn.addVirtualAuthenticatorrS   paramsauthenticatorId)r?   r   r   r   )rX   r[   rU   r   r   r   r   add_virtual_authenticator   s   	r]   authenticator_idc                 c  (    t  }|  |d< d|d}|V }dS )zH
    Removes the given authenticator.

    :param authenticator_id:
    r\   z#WebAuthn.removeVirtualAuthenticatorrZ   Nr?   r   r^   r[   rU   r   r   r   r   remove_virtual_authenticator      
rb   
credentialc                 c  s4    t  }|  |d< | |d< d|d}|V }dS )zr
    Adds the credential to the specified authenticator.

    :param authenticator_id:
    :param credential:
    r\   rd   zWebAuthn.addCredentialrZ   Nr`   )r^   rd   r[   rU   r   r   r   r   add_credential   s   

re   rD   r	   6typing.Generator[T_JSON_DICT, T_JSON_DICT, Credential]c                 c  s:    t  }|  |d< ||d< d|d}|V }t|d S )z
    Returns a single credential stored in the given virtual authenticator that
    matches the credential ID.

    :param authenticator_id:
    :param credential_id:
    :returns: 
    r\   rK   zWebAuthn.getCredentialrZ   rd   )r?   r   rC   r   r^   rD   r[   rU   r   r   r   r   get_credential   s   rh   Ctyping.Generator[T_JSON_DICT, T_JSON_DICT, typing.List[Credential]]c                 c  s6    t  }|  |d< d|d}|V }dd |d D S )z}
    Returns all the credentials stored in the given virtual authenticator.

    :param authenticator_id:
    :returns: 
    r\   zWebAuthn.getCredentialsrZ   c                 S  s   g | ]}t |qS r   )rC   r   ).0ir   r   r   
<listcomp>  s    z#get_credentials.<locals>.<listcomp>credentialsr`   ra   r   r   r   get_credentials   s   	rn   c                 c  0    t  }|  |d< ||d< d|d}|V }dS )zn
    Removes a credential from the authenticator.

    :param authenticator_id:
    :param credential_id:
    r\   rK   zWebAuthn.removeCredentialrZ   Nr`   rg   r   r   r   remove_credential  s   

rp   c                 c  r_   )z]
    Clears all the credentials from the specified device.

    :param authenticator_id:
    r\   zWebAuthn.clearCredentialsrZ   Nr`   ra   r   r   r   clear_credentials  rc   rq   r:   rA   c                 c  ro   )z
    Sets whether User Verification succeeds or fails for an authenticator.
    The default is true.

    :param authenticator_id:
    :param is_user_verified:
    r\   r>   zWebAuthn.setUserVerifiedrZ   Nr`   )r^   r:   r[   rU   r   r   r   r   set_user_verified,  s   
rr   )r   rQ   )rX   r4   r   rY   )r^   r   r   rQ   )r^   r   rd   rC   r   rQ   )r^   r   rD   r	   r   rf   )r^   r   r   ri   )r^   r   rD   r	   r   rQ   )r^   r   r:   rA   r   rQ   )
__future__r   utilr   r   dataclassesr   enumtypingr	   r   Enumr    r)   r4   rC   rV   rW   r]   rb   re   rh   rn   rp   rq   rr   r   r   r   r   <module>   s,   -
-








