zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
U
\±d“ã@sˆddlZddlZddlmZddlmZddlmZGdd„deeƒZGdd„deeƒZ    Gd    d
„d
ƒZ
Gd d „d ƒZ d d„Z dd„Z dS)éN)Úurlsafe_b64decode)Úurlsafe_b64encode)ÚEnumc@s*eZdZUdZdZeed<dZeed<dS)ÚProtocolz/Protocol to communicate with the authenticator.Zctap2ÚCTAP2z    ctap1/u2fÚU2FN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__rÚstrÚ__annotations__r©rrúfd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\selenium/webdriver/common/virtual_authenticator.pyrs
 rc@sBeZdZUdZdZeed<dZeed<dZeed<dZ    eed    <d
S) Ú    Transportz7Transport method to communicate with the authenticator.ZbleÚBLEZusbÚUSBZnfcÚNFCZinternalÚINTERNALN)
rr    r
r rr r rrrrrrrr s
 
   rc    @sbeZdZeZeZejejddddfeeeeeeddœdd„Z    e
j ee
j eeffdœdd    „Z dS)
ÚVirtualAuthenticatorOptionsFTN)ÚprotocolÚ    transportÚhas_resident_keyÚhas_user_verificationÚis_user_consentingÚis_user_verifiedÚreturncCs(||_||_||_||_||_||_dS)zMConstructor.
 
        Initialize VirtualAuthenticatorOptions object.
        N©rrrrrr)ÚselfrrrrrrrrrÚ__init__/s z$VirtualAuthenticatorOptions.__init__©rcCs|j|j|j|j|j|jdœS)N)rrZhasResidentKeyZhasUserVerificationZisUserConsentingZisUserVerifiedr©rrrrÚto_dictDsúz#VirtualAuthenticatorOptions.to_dict)rr    r
rrrrr ÚboolrÚtypingÚDictÚUnionr"rrrrr)s$ùø rc@s eZdZeeeejeeedœdd„Z    e
edœdd„ƒZ e
edœdd„ƒZ e
edœd    d
„ƒZ e
ejedœd d „ƒZe
edœd d„ƒZe
edœdd„ƒZeeeeeddœdd„ƒZeeeejeeeddœdd„ƒZejeejfdœdd„Zeejeejfddœdd„ƒZedœdd„ZdS)Ú
Credential)Ú credential_idÚis_resident_credentialÚrp_idÚ user_handleÚ private_keyÚ
sign_countcCs(||_||_||_||_||_||_dS)ahConstructor. 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)rr(r)r*r+r,r-rrrrPs zCredential.__init__r cCst|jƒ ¡S©N)rr.Údecoder!rrrÚidksz Credential.idcCs|jSr4)r/r!rrrr)osz!Credential.is_resident_credentialcCs|jSr4)r0r!rrrr*sszCredential.rp_idcCs|jrt|jƒ ¡SdSr4)r1rr5r!rrrr+wszCredential.user_handlecCst|jƒ ¡Sr4)rr2r5r!rrrr,}szCredential.private_keycCs|jSr4)r3r!rrrr-szCredential.sign_count)r6r*r,r-rcCs||d|d||ƒS)auCreates 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)Úclsr6r*r,r-rrrÚcreate_non_resident_credential…s z)Credential.create_non_resident_credential)r6r*r+r,r-rcCs||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)r7r6r*r+r,r-rrrÚcreate_resident_credential”sz%Credential.create_resident_credentialcCs.|j|j|j|j|jdœ}|jr*|j|d<|S)N)Ú credentialIdÚisResidentCredentialÚrpIdÚ
privateKeyÚ    signCountÚ
userHandle)r6r/r*r,r-r+)rZcredential_datarrrr"¦sû
zCredential.to_dict)ÚdatarcCs|t|d›dƒ}t|dƒ}| dd¡}t|d›dƒ}t|dƒ}| dd¡rft|d›dƒnd}|||||||ƒS)Nr:z==r;r<r=r>r?)rr#ÚgetÚint)r7r@r.r)r*r,r-r+rrrÚ    from_dict´s   "zCredential.from_dictc Cs6d|j›d|j›d|j›d|j›d|j›d|j›d S)NzCredential(id=z, is_resident_credential=z, rp_id=z,            user_handle=z, private_key=z , sign_count=ú))r6r)r*r+r,r-r!rrrÚ__str__¿sÿÿÿzCredential.__str__N)rr    r
Úbytesr#r r$ÚOptionalrBrÚpropertyr6r)r*r+r,r-Ú classmethodr8r9r%ÚAnyr"rCrErrrrr'OsBù þ
r'cst ˆ¡‡fdd„ƒ}|S)zKA decorator to ensure that the client used is a chromium based
    browser.cs*|jd ¡dkstdƒ‚ˆ|f|ž|ŽS)NZ browserName)ZfirefoxZsafariz4This only currently works in Chromium based browsers)ZcapsÚlowerÚAssertionError©rÚargsÚkwargs©ÚfuncrrÚwrapperÈsýz0required_chromium_based_browser.<locals>.wrapper)Ú    functoolsÚwraps©rQrRrrPrÚrequired_chromium_based_browserÄsrVcst ˆ¡t‡fdd„ƒƒ}|S)zSA decorator to ensure that the function is called with a virtual
    authenticator.cs|jstdƒ‚ˆ|f|ž|ŽS)Nz9This function requires a virtual authenticator to be set.)Zvirtual_authenticator_idÚ
ValueErrorrMrPrrrR×sz/required_virtual_authenticator.<locals>.wrapper)rSrTrVrUrrPrÚrequired_virtual_authenticatorÓsrX)rSr$Úbase64rrÚenumrr rrrr'rVrXrrrrÚ<module>s       &u