|
22 | 22 | from enum import Enum
|
23 | 23 |
|
24 | 24 |
|
25 |
| -class Protocol(Enum): |
26 |
| - """Protocol to communicate with the authenticator.""" |
| 25 | +class Protocol(str, Enum): |
| 26 | + CTAP2: str = "ctap2" |
| 27 | + U2F: str = "ctap1/u2f" |
27 | 28 |
|
28 |
| - CTAP2 = "ctap2" |
29 |
| - U2F = "ctap1/u2f" |
30 | 29 |
|
31 |
| - |
32 |
| -class Transport(Enum): |
| 30 | +class Transport(str, Enum): |
33 | 31 | """Transport method to communicate with the authenticator."""
|
34 | 32 |
|
35 |
| - BLE = "ble" |
36 |
| - USB = "usb" |
37 |
| - NFC = "nfc" |
38 |
| - INTERNAL = "internal" |
| 33 | + BLE: str = "ble" |
| 34 | + USB: str = "usb" |
| 35 | + NFC: str = "nfc" |
| 36 | + INTERNAL: str = "internal" |
39 | 37 |
|
40 | 38 |
|
41 | 39 | class VirtualAuthenticatorOptions:
|
42 | 40 |
|
| 41 | + # These are so unnecessary but are now public API so we can't remove them without deprecating first. |
| 42 | + # These should not be class level state in here. |
43 | 43 | Protocol = Protocol
|
44 | 44 | Transport = Transport
|
45 | 45 |
|
46 | 46 | def __init__(self) -> None:
|
47 |
| - """Constructor. Initialize VirtualAuthenticatorOptions object. |
48 |
| -
|
49 |
| - :default: |
50 |
| - - protocol: Protocol.CTAP2 |
51 |
| - - transport: Transport.USB |
52 |
| - - hasResidentKey: False |
53 |
| - - hasUserVerification: False |
54 |
| - - isUserConsenting: True |
55 |
| - - isUserVerified: False |
56 |
| - """ |
57 |
| - |
58 |
| - self._protocol: Protocol = Protocol.CTAP2 |
59 |
| - self._transport: Transport = Transport.USB |
60 |
| - self._has_resident_key: bool = False |
61 |
| - self._has_user_verification: bool = False |
62 |
| - self._is_user_consenting: bool = True |
63 |
| - self._is_user_verified: bool = False |
64 |
| - |
65 |
| - @property |
66 |
| - def protocol(self) -> str: |
67 |
| - return self._protocol.value |
68 |
| - |
69 |
| - @protocol.setter |
70 |
| - def protocol(self, protocol: Protocol) -> None: |
71 |
| - self._protocol = protocol |
72 |
| - |
73 |
| - @property |
74 |
| - def transport(self) -> str: |
75 |
| - return self._transport.value |
76 |
| - |
77 |
| - @transport.setter |
78 |
| - def transport(self, transport: Transport) -> None: |
79 |
| - self._transport = transport |
80 |
| - |
81 |
| - @property |
82 |
| - def has_resident_key(self) -> bool: |
83 |
| - return self._has_resident_key |
| 47 | + """Constructor. |
84 | 48 |
|
85 |
| - @has_resident_key.setter |
86 |
| - def has_resident_key(self, value: bool) -> None: |
87 |
| - self._has_resident_key = value |
88 |
| - |
89 |
| - @property |
90 |
| - def has_user_verification(self) -> bool: |
91 |
| - return self._has_user_verification |
92 |
| - |
93 |
| - @has_user_verification.setter |
94 |
| - def has_user_verification(self, value: bool) -> None: |
95 |
| - self._has_user_verification = value |
96 |
| - |
97 |
| - @property |
98 |
| - def is_user_consenting(self) -> bool: |
99 |
| - return self._is_user_consenting |
100 |
| - |
101 |
| - @is_user_consenting.setter |
102 |
| - def is_user_consenting(self, value: bool) -> None: |
103 |
| - self._is_user_consenting = value |
104 |
| - |
105 |
| - @property |
106 |
| - def is_user_verified(self) -> bool: |
107 |
| - return self._is_user_verified |
| 49 | + Initialize VirtualAuthenticatorOptions object. |
| 50 | + """ |
108 | 51 |
|
109 |
| - @is_user_verified.setter |
110 |
| - def is_user_verified(self, value: bool) -> None: |
111 |
| - self._is_user_verified = value |
| 52 | + self.protocol: str = Protocol.CTAP2 |
| 53 | + self.transport: str = Transport.USB |
| 54 | + self.has_resident_key: bool = False |
| 55 | + self.has_user_verification: bool = False |
| 56 | + self.is_user_consenting: bool = True |
| 57 | + self.is_user_verified: bool = False |
112 | 58 |
|
113 |
| - def to_dict(self) -> typing.Dict[str, typing.Any]: |
| 59 | + def to_dict(self) -> typing.Dict[str, typing.Union[str, bool]]: |
114 | 60 | return {
|
115 | 61 | "protocol": self.protocol,
|
116 | 62 | "transport": self.transport,
|
|
0 commit comments