1616# under the License.
1717
1818import functools
19- import typing
2019from base64 import urlsafe_b64decode
2120from base64 import urlsafe_b64encode
2221from enum import Enum
22+ from typing import Any
23+ from typing import Dict
24+ from typing import Optional
25+ from typing import Union
2326
2427
2528class Protocol (str , Enum ):
@@ -65,7 +68,7 @@ def __init__(
6568 self .is_user_consenting : bool = is_user_consenting
6669 self .is_user_verified : bool = is_user_verified
6770
68- def to_dict (self ) -> typing . Dict [str , typing . Union [str , bool ]]:
71+ def to_dict (self ) -> Dict [str , Union [str , bool ]]:
6972 return {
7073 "protocol" : self .protocol ,
7174 "transport" : self .transport ,
@@ -82,7 +85,7 @@ def __init__(
8285 credential_id : bytes ,
8386 is_resident_credential : bool ,
8487 rp_id : str ,
85- user_handle : typing . Optional [bytes ],
88+ user_handle : Optional [bytes ],
8689 private_key : bytes ,
8790 sign_count : int ,
8891 ):
@@ -117,7 +120,7 @@ def rp_id(self) -> str:
117120 return self ._rp_id
118121
119122 @property
120- def user_handle (self ) -> typing . Optional [str ]:
123+ def user_handle (self ) -> Optional [str ]:
121124 if self ._user_handle :
122125 return urlsafe_b64encode (self ._user_handle ).decode ()
123126 return None
@@ -147,7 +150,7 @@ def create_non_resident_credential(cls, id: bytes, rp_id: str, private_key: byte
147150
148151 @classmethod
149152 def create_resident_credential (
150- cls , id : bytes , rp_id : str , user_handle : typing . Optional [bytes ], private_key : bytes , sign_count : int
153+ cls , id : bytes , rp_id : str , user_handle : Optional [bytes ], private_key : bytes , sign_count : int
151154 ) -> "Credential" :
152155 """Creates a resident (i.e. stateful) credential.
153156
@@ -163,7 +166,7 @@ def create_resident_credential(
163166 """
164167 return cls (id , True , rp_id , user_handle , private_key , sign_count )
165168
166- def to_dict (self ) -> typing . Dict [str , typing . Any ]:
169+ def to_dict (self ) -> Dict [str , Any ]:
167170 credential_data = {
168171 "credentialId" : self .id ,
169172 "isResidentCredential" : self ._is_resident_credential ,
@@ -178,7 +181,7 @@ def to_dict(self) -> typing.Dict[str, typing.Any]:
178181 return credential_data
179182
180183 @classmethod
181- def from_dict (cls , data : typing . Dict [str , typing . Any ]) -> "Credential" :
184+ def from_dict (cls , data : Dict [str , Any ]) -> "Credential" :
182185 _id = urlsafe_b64decode (f"{ data ['credentialId' ]} ==" )
183186 is_resident_credential = bool (data ["isResidentCredential" ])
184187 rp_id = data .get ("rpId" , None )
0 commit comments