
    ,iA                         d dl Z d dlmZmZ d dlmZ d dlmZmZ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y)    N)urlsafe_b64decodeurlsafe_b64encode)Enum)AnyOptionalUnionc                       e Zd ZdZdZdZy)Protocolz/Protocol to communicate with the authenticator.ctap2z	ctap1/u2fN)__name__
__module____qualname____doc__CTAP2U2F     ~/var/www/system.tvplus.app.br/jogos/scrap/venv/lib/python3.12/site-packages/selenium/webdriver/common/virtual_authenticator.pyr
   r
      s    9E
Cr   r
   c                        e Zd ZdZdZdZdZdZy)	Transportz7Transport method to communicate with the authenticator.bleusbnfcinternalN)r   r   r   r   BLEUSBNFCINTERNALr   r   r   r   r      s    A
C
C
CHr   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
eeeef   f   fdZy
)VirtualAuthenticatorOptionsFTprotocol	transporthas_resident_keyhas_user_verificationis_user_consentingis_user_verifiedreturnNc                 X    || _         || _        || _        || _        || _        || _        y)zMConstructor.

        Initialize VirtualAuthenticatorOptions object.
        Nr!   r"   r#   r$   r%   r&   )selfr!   r"   r#   r$   r%   r&   s          r   __init__z$VirtualAuthenticatorOptions.__init__.   s2     &'&6+@"(:&6r   c                     | j                   | j                  | j                  | j                  | j                  | j
                  dS )N)r!   r"   hasResidentKeyhasUserVerificationisUserConsentingisUserVerifiedr)   r*   s    r   to_dictz#VirtualAuthenticatorOptions.to_dictC   s>    "33#'#=#= $ 7 7"33
 	
r   )r   r   r   r
   r   r   r   strboolr+   dictr   r2   r   r   r   r    r    (   s     HI !"!&&+#'!&77 7 	7
  $7 !7 7 
7*
c5d#334 
r   r    c                   ^   e Zd Zdededee   de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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e   dededd fd       Zdeeef   fdZedeeef   dd fd       ZdefdZy)
Credentialcredential_idis_resident_credentialrp_iduser_handleprivate_key
sign_countc                 X    || _         || _        || _        || _        || _        || _        y)ae  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): initial 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__O   s2    ( !'=$''%r   r'   c                 H    t        | j                        j                         S N)r   r?   decoder1   s    r   idzCredential.idj   s     *1133r   c                     | j                   S rF   )r@   r1   s    r   r9   z!Credential.is_resident_credentialn   s    +++r   c                     | j                   S rF   )rA   r1   s    r   r:   zCredential.rp_idr   s    {{r   c                 b    | j                   r#t        | j                         j                         S y rF   )rB   r   rG   r1   s    r   r;   zCredential.user_handlev   s(    $T%6%67>>@@r   c                 H    t        | j                        j                         S rF   )r   rC   rG   r1   s    r   r<   zCredential.private_key|   s     !2!23::<<r   c                     | j                   S rF   )rD   r1   s    r   r=   zCredential.sign_count   s    r   rH   c                      | |d|d||      S )as  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): initial 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     2ueT;
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): initial 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      2tUKjIIr   c                     | 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   r2   zCredential.to_dict   sQ     GG$($@$@JJ**
 ,0,<,<OL)r   datac                    t        |d    d      }t        |d         }|j                  dd       }t        |d    d      }t        |d         }|j                  dd       rt        |d    d      nd } | ||||||      S )NrT   z==rU   rV   rW   rX   rY   )r   r4   getint)rO   r[   r?   r9   r:   r<   r=   r;   s           r   	from_dictzCredential.from_dict   s    4#7"8 ;<!%d+A&B!C&'4+=*>b(ABk*+
FJhh|]aFb'4+=*>b(ABhl3.{KQ[\\r   c                     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=   r1   s    r   __str__zCredential.__str__   sf    y(A$B]B]A^^fgkgqgqfr s))*.9I9I8J-X\XgXgWhhik 	kr   N)r   r   r   bytesr4   r   r3   r^   r+   propertyrH   r9   r:   r;   r<   r=   classmethodrP   rR   r5   r   r2   r_   rb   r   r   r   r7   r7   N   s   && !%& }	&
 e_& & &6 4C 4 4 , , , s   Xc]  
 =S = =  C     D Dc DPU Dcf Dkw D D JJ"J19%JOTJbeJ	J J"c3h  ]T#s(^ ] ] ]k kr   r7   c                 B     t        j                          fd       }|S )zKA decorator to ensure that the client used is a chromium based
    browser.c                 h    | j                   d   j                         dvsJ d        | g|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   sP    yy'--/ 8
 
 	B B	B 
 D*4*6**r   )	functoolswrapsrp   rq   s   ` r   required_chromium_based_browserru      s'     __T+ + Nr   c                 T     t        j                         t         fd              }|S )zSA decorator to ensure that the function is called with a virtual
    authenticator.c                 J    | j                   st        d       | g|i |S )Nz9This function requires a virtual authenticator to be set.)virtual_authenticator_id
ValueErrorrm   s      r   rq   z/required_virtual_authenticator.<locals>.wrapper   s/     ,,XYYD*4*6**r   )rr   rs   ru   rt   s   ` r   required_virtual_authenticatorrz      s/     __T$+ % +
 Nr   )rr   base64r   r   enumr   typingr   r   r   r3   r
   r   r    r7   ru   rz   r   r   r   <module>r~      sV   $  7  ' 'sD T #
 #
Lrk rkjr   