
    ,h                         d dl Z d dlmZ d dlmZ d dlmZ d dlm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y)    N)urlsafe_b64decode)urlsafe_b64encode)Enum)Any)Dict)Optional)Unionc                   .    e Zd ZU dZdZeed<   dZeed<   y)Protocolz/Protocol to communicate with the authenticator.ctap2CTAP2z	ctap1/u2fU2FN)__name__
__module____qualname____doc__r   str__annotations__r        q/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/selenium/webdriver/common/virtual_authenticator.pyr   r      s    9E3Cr   r   c                   J    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	<   y
)	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   #   s-    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
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__2   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_dictG   s>    "33#'#=#= $ 7 7"33
 	
r   )r   r   r   r   r   r   r   r   boolr.   r   r	   r5   r   r   r   r#   r#   ,   s     HI !"!&&+#'!&77 7 	7
  $7 !7 7 
7*
c5d#334 
r   r#   c                   X   e Zd Zdeded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)ar  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-   r9   r:   r;   r<   r=   r>   s          r   r.   zCredential.__init__S   s2    ( !'=$''%r   r*   c                 H    t        | j                        j                         S N)r   r@   decoder4   s    r   idzCredential.idn   s     *1133r   c                     | j                   S rG   )rA   r4   s    r   r:   z!Credential.is_resident_credentialr   s    +++r   c                     | j                   S rG   )rB   r4   s    r   r;   zCredential.rp_idv   s    {{r   c                 b    | j                   r#t        | j                         j                         S y rG   )rC   r   rH   r4   s    r   r<   zCredential.user_handlez   s(    $T%6%67>>@@r   c                 H    t        | j                        j                         S rG   )r   rD   rH   r4   s    r   r=   zCredential.private_key   s     !2!23::<<r   c                     | j                   S rG   )rE   r4   s    r   r>   zCredential.sign_count   s    r   rI   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   )clsrI   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): intital value for a signature counter.

        :returns:
          - Credential: A resident credential.
        Tr   )rP   rI   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)rI   rA   r;   r=   r>   r<   )r-   credential_datas     r   r5   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 )NrU   z==rV   rW   rX   rY   rZ   )r   r6   getint)rP   r\   r@   r:   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=))rI   r:   r;   r<   r=   r>   r4   s    r   __str__zCredential.__str__   sf    y(A$B]B]A^^fgkgqgqfr s))*.9I9I8J-X\XgXgWhhik 	kr   N)r   r   r   bytesr6   r   r   r_   r.   propertyrI   r:   r;   r<   r=   r>   classmethodrQ   rS   r   r   r5   r`   rc   r   r   r   r8   r8   R   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   r8   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   sK    yy'--/ 8
 
 	B B	B D*4*6**r   )	functoolswrapsrq   rr   s   ` r   required_chromium_based_browserrv      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
ValueErrorrn   s      r   rr   z/required_virtual_authenticator.<locals>.wrapper   s/     ,,XYYD*4*6**r   )rs   rt   rv   ru   s   ` r   required_virtual_authenticatorr{      s/     __T$+ % +
 Nr   )rs   base64r   r   enumr   typingr   r   r   r	   r   r   r   r#   r8   rv   r{   r   r   r   <module>r      s_   $  $ $     sD T #
 #
Lrk rkjr   