2023-09-13 13:46:38 +00:00
|
|
|
"""Credentials class for username / passwords."""
|
|
|
|
|
2024-11-13 17:50:21 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
import base64
|
2023-09-13 13:46:38 +00:00
|
|
|
from dataclasses import dataclass, field
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class Credentials:
|
|
|
|
"""Credentials for authentication."""
|
|
|
|
|
2024-01-03 18:26:52 +00:00
|
|
|
#: Username (email address) of the cloud account
|
|
|
|
username: str = field(default="", repr=False)
|
|
|
|
#: Password of the cloud account
|
|
|
|
password: str = field(default="", repr=False)
|
2024-11-13 17:50:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
def get_default_credentials(tuple: tuple[str, str]) -> Credentials:
|
|
|
|
"""Return decoded default credentials."""
|
|
|
|
un = base64.b64decode(tuple[0].encode()).decode()
|
|
|
|
pw = base64.b64decode(tuple[1].encode()).decode()
|
|
|
|
return Credentials(un, pw)
|
|
|
|
|
|
|
|
|
|
|
|
DEFAULT_CREDENTIALS = {
|
|
|
|
"KASA": ("a2FzYUB0cC1saW5rLm5ldA==", "a2FzYVNldHVw"),
|
|
|
|
"TAPO": ("dGVzdEB0cC1saW5rLm5ldA==", "dGVzdA=="),
|
|
|
|
"TAPOCAMERA": ("YWRtaW4=", "YWRtaW4="),
|
|
|
|
}
|