2026-02-06 01:29:26 +01:00
|
|
|
import requests
|
|
|
|
|
import base64
|
2026-02-06 04:00:43 +01:00
|
|
|
from argon2 import PasswordHasher
|
2026-02-06 01:29:26 +01:00
|
|
|
|
|
|
|
|
API_URL = "https://account.spfn.net/api/v2"
|
2026-02-06 04:00:43 +01:00
|
|
|
ph = PasswordHasher()
|
|
|
|
|
|
|
|
|
|
def hash_password(password: str):
|
|
|
|
|
return ph.hash(password)
|
|
|
|
|
|
|
|
|
|
def verify_password(hashed: str, password: str):
|
|
|
|
|
try:
|
|
|
|
|
return ph.verify(hashed, password)
|
|
|
|
|
except Exception:
|
|
|
|
|
return False
|
2026-02-06 01:29:26 +01:00
|
|
|
|
|
|
|
|
def get_token(username, password):
|
|
|
|
|
creds = f"{username} {password}"
|
|
|
|
|
encoded = base64.b64encode(creds.encode()).decode()
|
|
|
|
|
|
|
|
|
|
headers = {
|
|
|
|
|
"Authorization": f"Basic {encoded}",
|
|
|
|
|
"User-Agent": "saturday & allison should lwk kiss..."
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
response = requests.get(f"{API_URL}/oauth2/generate_token", headers=headers, timeout=10)
|
2026-02-06 04:00:43 +01:00
|
|
|
return response.json() if response.ok else None
|
2026-02-06 01:29:26 +01:00
|
|
|
|
|
|
|
|
def get_profile(token):
|
|
|
|
|
headers = {
|
|
|
|
|
"Authorization": f"Bearer {token}",
|
|
|
|
|
"User-Agent": "every update im going to change this user agent because im bored!!"
|
|
|
|
|
}
|
|
|
|
|
response = requests.get(f"{API_URL}/users/@me/profile", headers=headers, timeout=10)
|
|
|
|
|
return response.text if response.ok else None
|