
    i                         d dl Z d dlmZ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)Anyc                       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     k/var/www/html/BatchJob/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z  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_dictB   s>    "33#'#=#= $ 7 7"33
 	
r   )r
   r   r   r   r   r   r   strboolr)   dictr0   r   r   r   r   r   (   s     HI !"!&&+#'!&77 7 	7
  $7 !7 7 
7(
c3:o. 
r   r   c                   d   e Zd Zdedededz  dedz  dedefdZed	efd
       Z	ed	efd       Z
ed	edz  fd       Zed	edz  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dz  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_idNuser_handleprivate_key
sign_countc                 X    || _         || _        || _        || _        || _        || _        y)af  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(   r6   r7   r8   r9   r:   r;   s          r   r)   zCredential.__init__N   s2    * !'=$''%r   r%   c                 H    t        | j                        j                         S N)r   r=   decoder/   s    r   idzCredential.idj   s     *1133r   c                     | j                   S rD   )r>   r/   s    r   r7   z!Credential.is_resident_credentialn   s    +++r   c                     | j                   S rD   )r?   r/   s    r   r8   zCredential.rp_idr   s    {{r   c                 b    | j                   r#t        | j                         j                         S y rD   )r@   r   rE   r/   s    r   r9   zCredential.user_handlev   s(    $T%6%67>>@@r   c                 H    t        | j                        j                         S rD   )r   rA   rE   r/   s    r   r:   zCredential.private_key|   s     !2!23::<<r   c                     | j                   S rD   )rB   r/   s    r   r;   zCredential.sign_count   s    r   rF   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   )clsrF   r8   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   )rM   rF   r8   r9   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)rF   r>   r8   r:   r;   r9   )r(   credential_datas     r   r0   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 )NrR   z==rS   rT   rU   rV   rW   )r   r2   getint)rM   rY   r=   r7   r8   r:   r;   r9   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=))rF   r7   r8   r9   r:   r;   r/   s    r   __str__zCredential.__str__   sf    y(A$B]B]A^^fgkgqgqfr s))*.9I9I8J-X\XgXgWhhik 	kr   )r
   r   r   bytesr2   r1   r\   r)   propertyrF   r7   r8   r9   r:   r;   classmethodrN   rP   r3   r   r0   r]   r`   r   r   r   r5   r5   M   s   && !%& Tz	&
 T\& & &8 4C 4 4 , , , sTz   S4Z  
 =S = =  C     D Dc DPU Dcf Dkw D D JJ"J16JLQJ_bJ	J J"c3h  ]T#s(^ ] ] ]k kr   r5   c                 B     t        j                          fd       }|S )zEDecorator 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rn   ro   s   ` r   required_chromium_based_browserrs      s'     __T+ + Nr   c                 T     t        j                         t         fd              }|S )zMDecorator 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
ValueErrorrk   s      r   ro   z/required_virtual_authenticator.<locals>.wrapper   s/     ,,XYYD*4*6**r   )rp   rq   rs   rr   s   ` r   required_virtual_authenticatorrx      s/     __T$+ % +
 Nr   )rp   base64r   r   enumr   typingr   r1   r   r   r   r5   rs   rx   r   r   r   <module>r|      sS   $  7  sD T "
 "
Jsk skl
r   