Compare commits

..

2 Commits

Author SHA1 Message Date
053bb8696f feat: add a method to load configuration 2025-12-14 17:15:31 +01:00
a31df05bb8 feat: define authentication logic to at protocol 2025-12-14 17:15:22 +01:00
2 changed files with 32 additions and 0 deletions

25
skywipe/auth.py Normal file
View File

@@ -0,0 +1,25 @@
"""Authentication module for Skywipe CLI."""
from atproto import Client
from skywipe.configure import Configuration
class Auth:
def __init__(self, configuration: Configuration = None):
self.configuration = configuration or Configuration()
self.client: Client = None
def login(self) -> Client:
config_data = self.configuration.load()
handle = config_data.get("handle")
password = config_data.get("password")
if not handle or not password:
raise ValueError(
"handle and password must be set in configuration")
self.client = Client()
self.client.login(handle, password)
return self.client

View File

@@ -52,3 +52,10 @@ class Configuration:
yaml.dump(config_data, f, default_flow_style=False)
print(f"\nConfiguration saved to {self.config_file}")
def load(self) -> dict:
if not self.exists():
raise FileNotFoundError(
f"Configuration file not found: {self.config_file}")
with open(self.config_file, "r") as f:
return yaml.safe_load(f)