a
    $ñ»jÿO  ã                   @  sÄ  d dl mZ d dlZd dlZd dlmZ ddlmZmZ G dd„ de	ƒZ
G dd	„ d	ejƒ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dCdddœdd„Zddœdd„Zdddœdd„ZdDddddddœdd „Zddd!œd"d#„Zdddd$œd%d&„Zdd'd(d)œd*d+„Zdd,d!œd-d.„Zdd'dd)œd/d0„Zddd!œd1d2„Zdd3dd4œd5d6„Zdd3dd7œd8d9„ZdEdd'dddd:œd;d<„Zed=ƒeG d>d?„ d?ƒƒƒZed@ƒeG dAdB„ dBƒƒƒZdS )Fé    )ÚannotationsN)Ú	dataclassé   )Úevent_classÚT_JSON_DICTc                      s>   e Zd Zddœdd„Zedd dœdd„ƒZ‡ fdd	„Z‡  ZS )
ÚAuthenticatorIdÚstr©Úreturnc                 C  s   | S ©N© ©Úselfr   r   ú5E:\soccer\ml_env\Lib\site-packages\mycdp/web_authn.pyÚto_json   s    zAuthenticatorId.to_json©Újsonr
   c                 C  s   | |ƒS r   r   ©Úclsr   r   r   r   Ú	from_json   s    zAuthenticatorId.from_jsonc                   s   d  tƒ  ¡ ¡S )NzAuthenticatorId({}))ÚformatÚsuperÚ__repr__r   ©Ú	__class__r   r   r      s    zAuthenticatorId.__repr__)Ú__name__Ú
__module__Ú__qualname__r   Úclassmethodr   r   Ú__classcell__r   r   r   r   r      s   r   c                   @  s6   e Zd ZdZdZddœdd„Zedd dœdd	„ƒZd
S )ÚAuthenticatorProtocolZu2fZctap2r   r	   c                 C  s   | j S r   ©Úvaluer   r   r   r   r      s    zAuthenticatorProtocol.to_jsonr   c                 C  s   | |ƒS r   r   r   r   r   r   r   "   s    zAuthenticatorProtocol.from_jsonN)r   r   r   ZU2FZCTAP2r   r   r   r   r   r   r   r       s
   r    c                   @  s6   e Zd ZdZdZddœdd„Zedd dœdd	„ƒZd
S )ÚCtap2VersionZctap2_0Zctap2_1r   r	   c                 C  s   | j S r   r!   r   r   r   r   r   +   s    zCtap2Version.to_jsonr   c                 C  s   | |ƒS r   r   r   r   r   r   r   .   s    zCtap2Version.from_jsonN)r   r   r   ZCTAP2_0ZCTAP2_1r   r   r   r   r   r   r   r#   '   s
   r#   c                   @  sB   e Zd ZdZdZdZdZdZddœdd	„Ze	dd d
œdd„ƒZ
dS )ÚAuthenticatorTransportZusbZnfcZbleZcableZinternalr   r	   c                 C  s   | j S r   r!   r   r   r   r   r   :   s    zAuthenticatorTransport.to_jsonr   c                 C  s   | |ƒS r   r   r   r   r   r   r   =   s    z AuthenticatorTransport.from_jsonN)r   r   r   ZUSBÚNFCZBLEZCABLEZINTERNALr   r   r   r   r   r   r   r$   3   s   r$   c                   @  sÄ   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Zded< dZ	ded< dZ
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œdd„Zedd dœdd„ƒZdS )ÚVirtualAuthenticatorOptionsr    Úprotocolr$   Ú	transportNztyping.Optional[Ctap2Version]Úctap2_versionútyping.Optional[bool]Úhas_resident_keyÚhas_user_verificationÚhas_large_blobÚhas_cred_blobÚhas_min_pin_lengthÚhas_prfÚautomatic_presence_simulationÚis_user_verifiedÚdefault_backup_eligibilityÚdefault_backup_stater   r	   c                 C  s  t ƒ }| j ¡ |d< | j ¡ |d< | jd ur:| j ¡ |d< | jd urN| j|d< | jd urb| j|d< | jd urv| j|d< | jd urŠ| j|d< | j	d urž| j	|d< | j
d ur²| j
|d	< | jd urÆ| j|d
< | jd urÚ| j|d< | jd urî| j|d< | jd u�r| j|d< |S )Nr'   r(   Úctap2VersionÚhasResidentKeyÚhasUserVerificationÚhasLargeBlobÚhasCredBlobÚhasMinPinLengthÚhasPrfÚautomaticPresenceSimulationÚisUserVerifiedÚdefaultBackupEligibilityÚdefaultBackupState)Údictr'   r   r(   r)   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   ©r   r   r   r   r   r   j   s6    













ÿ




z#VirtualAuthenticatorOptions.to_jsonr   c                 C  sŽ  | t  | d¡¡t | d¡¡| dd ¡d ur>t | d¡¡nd | dd ¡d ur^t| d¡ƒnd | dd ¡d ur~t| d¡ƒnd | dd ¡d uržt| d¡ƒnd | dd ¡d ur¾t| d¡ƒnd | dd ¡d urÞt| d¡ƒnd | d	d ¡d urþt| d	¡ƒnd | d
d ¡d u�r t| d
¡ƒnd | dd ¡d u�rBt| d¡ƒnd | dd ¡d u�rdt| d¡ƒnd | dd ¡d u�r†t| d¡ƒnd d�S )Nr'   r(   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   )r'   r(   r)   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   )r    r   Úgetr$   r#   Úboolr   r   r   r   r   ˆ   sJ    ÿÿÿÿÿÿÿÿÿÿÿÈz%VirtualAuthenticatorOptions.from_json)r   r   r   Ú__annotations__r)   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r   r   r   r   r   r   r   r&   B   s    
r&   c                   @  sŒ   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Zd	ed< dZded< dZded< ddœdd„Z	e
dd dœdd„ƒZdS )Ú
Credentialr   Úcredential_idrC   Úis_resident_credentialÚprivate_keyÚintÚ
sign_countNztyping.Optional[str]Úrp_idÚuser_handleÚ
large_blobr*   Úbackup_eligibilityÚbackup_stater   r	   c                 C  s–   t ƒ }| j|d< | j|d< | j|d< | j|d< | jd urB| j|d< | jd urV| j|d< | jd urj| j|d< | jd ur~| j|d< | j	d ur’| j	|d	< |S )
NÚcredentialIdÚisResidentCredentialÚ
privateKeyÚ	signCountÚrpIdÚ
userHandleÚ	largeBlobÚbackupEligibilityÚbackupState)
r@   rF   rG   rH   rJ   rK   rL   rM   rN   rO   rA   r   r   r   r   å   s     













zCredential.to_jsonr   c                 C  sØ   | t | d¡ƒt| d¡ƒt | d¡ƒt| d¡ƒ| dd ¡d urPt | d¡ƒnd | dd ¡d urpt | d¡ƒnd | dd ¡d ur�t | d¡ƒnd | dd ¡d ur°t| d¡ƒnd | d	d ¡d urÐt| d	¡ƒnd d
�	S )NrP   rQ   rR   rS   rT   rU   rV   rW   rX   )	rF   rG   rH   rJ   rK   rL   rM   rN   rO   )r   rB   rC   rI   r   r   r   r   r   ÷   s*    ÿÿÿÿÿäzCredential.from_json)r   r   r   rD   rK   rL   rM   rN   rO   r   r   r   r   r   r   r   rE   Ç   s   
rE   r*   z0typing.Generator[T_JSON_DICT, T_JSON_DICT, None])Ú	enable_uir
   c                 c  s*   t ƒ }| dur| |d< d|dœ}|V }dS )aÖ  
    Enable the WebAuthn domain and start intercepting credential storage and
    retrieval with a virtual authenticator.
    :param enable_ui: *(Optional)*
     Whether to enable the WebAuthn user interface.
    Enabling the UI is recommended for debugging and demo purposes,
    as it is closer to the real experience.
    Disabling the UI is recommended for automated testing.
    Supported at the embedder's discretion if UI is available.
    Defaults to false.
    NZenableUIzWebAuthn.enable©ÚmethodÚparams)r@   )rY   r\   Úcmd_dictr   r   r   r   Úenable  s    þr^   r	   c                  c  s   ddi} | V }dS )zDisable the WebAuthn domain.r[   zWebAuthn.disableNr   )r]   r   r   r   r   Údisable2  s    ÿr_   z;typing.Generator[T_JSON_DICT, T_JSON_DICT, AuthenticatorId])Úoptionsr
   c                 c  s2   t ƒ }|  ¡ |d< d|dœ}|V }t | d¡¡S )zG
    Creates and adds a virtual authenticator.
    :param options:
    r`   z WebAuthn.addVirtualAuthenticatorrZ   ÚauthenticatorId)r@   r   r   r   rB   )r`   r\   r]   r   r   r   r   Úadd_virtual_authenticator:  s    þrb   )Úauthenticator_idÚis_bogus_signatureÚ	is_bad_uvÚ	is_bad_upr
   c                 c  sV   t ƒ }|  ¡ |d< |dur"||d< |dur2||d< |durB||d< d|dœ}|V }dS )af  
    Resets parameters isBogusSignature, isBadUV, isBadUP to false
    if they are not present.
    :param authenticator_id:
    :param is_bogus_signature: *(Optional)*
     If isBogusSignature is set, overrides the signature
     in the authenticator response to be zero. Defaults to false.
    :param is_bad_uv: *(Optional)*
     If isBadUV is set, overrides the UV bit in the flags
     in the authenticator response to be zero. Defaults to false.
    :param is_bad_up: *(Optional)*
     If isBadUP is set, overrides the UP bit in the flags
     in the authenticator response to be zero. Defaults to false.
    ra   NZisBogusSignatureZisBadUVZisBadUPz WebAuthn.setResponseOverrideBitsrZ   ©r@   r   )rc   rd   re   rf   r\   r]   r   r   r   r   Úset_response_override_bitsK  s    þrh   )rc   r
   c                 c  s&   t ƒ }|  ¡ |d< d|dœ}|V }dS )zG
    Removes the given authenticator.
    :param authenticator_id:
    ra   z#WebAuthn.removeVirtualAuthenticatorrZ   Nrg   ©rc   r\   r]   r   r   r   r   Úremove_virtual_authenticatorn  s    þrj   )rc   Ú
credentialr
   c                 c  s2   t ƒ }|  ¡ |d< | ¡ |d< d|dœ}|V }dS )zq
    Adds the credential to the specified authenticator.
    :param authenticator_id:
    :param credential:
    ra   rk   zWebAuthn.addCredentialrZ   Nrg   )rc   rk   r\   r]   r   r   r   r   Úadd_credential~  s    þrl   r   z6typing.Generator[T_JSON_DICT, T_JSON_DICT, Credential])rc   rF   r
   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:
    ra   rP   zWebAuthn.getCredentialrZ   rk   )r@   r   rE   r   rB   ©rc   rF   r\   r]   r   r   r   r   Úget_credential�  s    	þrn   zCtyping.Generator[T_JSON_DICT, T_JSON_DICT, typing.List[Credential]]c                 c  s4   t ƒ }|  ¡ |d< d|dœ}|V }dd„ |d D ƒS )zm
    Returns all the credentials stored in the given virtual authenticator.
    :param authenticator_id:
    ra   zWebAuthn.getCredentialsrZ   c                 S  s   g | ]}t  |¡‘qS r   )rE   r   )Ú.0Úir   r   r   Ú
<listcomp>²  ó    z#get_credentials.<locals>.<listcomp>Úcredentialsrg   ri   r   r   r   Úget_credentials¤  s    þrt   c                 c  s.   t ƒ }|  ¡ |d< ||d< d|dœ}|V }dS )zm
    Removes a credential from the authenticator.
    :param authenticator_id:
    :param credential_id:
    ra   rP   zWebAuthn.removeCredentialrZ   Nrg   rm   r   r   r   Úremove_credentialµ  s    þru   c                 c  s&   t ƒ }|  ¡ |d< d|dœ}|V }dS )z\
    Clears all the credentials from the specified device.
    :param authenticator_id:
    ra   zWebAuthn.clearCredentialsrZ   Nrg   ri   r   r   r   Úclear_credentialsÇ  s    þrv   rC   )rc   r2   r
   c                 c  s.   t ƒ }|  ¡ |d< ||d< d|dœ}|V }dS )z£
    Sets whether User Verification succeeds or fails for an authenticator.
    The default is true.
    :param authenticator_id:
    :param is_user_verified:
    ra   r=   zWebAuthn.setUserVerifiedrZ   Nrg   )rc   r2   r\   r]   r   r   r   r   Úset_user_verified×  s    	þrw   )rc   Úenabledr
   c                 c  s.   t ƒ }|  ¡ |d< ||d< d|dœ}|V }dS )zÒ
    Sets whether tests of user presence will succeed immediately (if true)
    or fail to resolve (if false) for an authenticator.
    The default is true.
    :param authenticator_id:
    :param enabled:
    ra   rx   z'WebAuthn.setAutomaticPresenceSimulationrZ   Nrg   )rc   rx   r\   r]   r   r   r   r   Ú!set_automatic_presence_simulationê  s    
þry   )rc   rF   rN   rO   r
   c                 c  sN   t ƒ }|  ¡ |d< ||d< |dur*||d< |dur:||d< d|dœ}|V }dS )a  
    Allows setting credential properties.
    https://w3c.github.io/webauthn/#sctn-automation-set-credential-properties
    :param authenticator_id:
    :param credential_id:
    :param backup_eligibility: *(Optional)*
    :param backup_state: *(Optional)*
    ra   rP   NrW   rX   z WebAuthn.setCredentialPropertiesrZ   rg   )rc   rF   rN   rO   r\   r]   r   r   r   r   Úset_credential_propertiesþ  s    þrz   zWebAuthn.credentialAddedc                   @  s6   e Zd ZU dZded< ded< edd dœdd	„ƒZd
S )ÚCredentialAddedz9Triggered when a credential is added to an authenticator.r   rc   rE   rk   r   r   c                 C  s"   | t  |d ¡t | d¡¡d�S ©Nra   rk   )rc   rk   ©r   r   rE   rB   r   r   r   r   r   !  s    ÿüzCredentialAdded.from_jsonN©r   r   r   Ú__doc__rD   r   r   r   r   r   r   r{     s
   
r{   zWebAuthn.credentialAssertedc                   @  s6   e Zd ZU dZded< ded< edd dœdd	„ƒZd
S )ÚCredentialAssertedz<Triggered when a credential is used in a webauthn assertion.r   rc   rE   rk   r   r   c                 C  s"   | t  |d ¡t | d¡¡d�S r|   r}   r   r   r   r   r   2  s    ÿüzCredentialAsserted.from_jsonNr~   r   r   r   r   r€   +  s
   
r€   )N)NNN)NN) Ú
__future__r   ÚenumÚtypingÚdataclassesr   Úutilr   r   r   r   ÚEnumr    r#   r$   r&   rE   r^   r_   rb   rh   rj   rl   rn   rt   ru   rv   rw   ry   rz   r{   r€   r   r   r   r   Ú<module>   sL    S ÿ   ü#  ü