Deprecate websafe_decode of bytes

This commit is contained in:
Dain Nilsson 2024-03-04 09:55:54 +01:00
parent a7f3c51aca
commit 9d8e8d167d
No known key found for this signature in database
GPG Key ID: F04367096FBA95E8
1 changed files with 8 additions and 0 deletions

View File

@ -49,6 +49,7 @@ from typing import (
get_type_hints,
)
import struct
import warnings
__all__ = [
"websafe_encode",
@ -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)