Skip to content

Commit

Permalink
Deprecate websafe_decode of bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
dainnilsson committed Mar 4, 2024
1 parent a7f3c51 commit 9d8e8d1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fido2/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
get_type_hints,
)
import struct
import warnings

__all__ = [
"websafe_encode",
Expand Down Expand Up @@ -121,6 +122,13 @@ def websafe_decode(data: Union[str, bytes]) -> bytes:
"""
if isinstance(data, str):
data = data.encode("ascii")
else:
warnings.warn(
"Calling websafe_decode on a byte value is deprecated, "
"and will no longer be allowed starting in python-fido2 2.0",
DeprecationWarning,
)

data += b"=" * (-len(data) % 4)
return urlsafe_b64decode(data)

Expand Down

0 comments on commit 9d8e8d1

Please sign in to comment.