Enhance Roblox API integration and refactor CLI commands

- Updated the `clap` dependency in `Cargo.toml` to include the "env" feature for improved command-line argument handling.
- Introduced a new `roblox_api` module to encapsulate Roblox API interactions, including authentication and asset downloading.
- Refactored the `CloneCommand` and `StudioCommand` to utilize the new `roblox_api` functions for fetching experience names and universe IDs, enhancing code clarity and reducing duplication.
- Removed obsolete functions related to Roblox API calls from the CLI commands, streamlining the codebase.
- Added error handling for authentication failures, ensuring better user feedback when required credentials are missing.

These changes aim to improve the overall structure and functionality of the CLI while enhancing the integration with the Roblox API.
This commit is contained in:
Joe 2026-03-01 20:03:40 -06:00
parent fb46515913
commit 9934094dbc
22 changed files with 2427 additions and 161 deletions

View file

@ -0,0 +1,32 @@
from __future__ import annotations
from cryptography.fernet import Fernet
_fernet: Fernet | None = None
def init_encryption(key: str) -> None:
global _fernet
if not key:
_fernet = Fernet(Fernet.generate_key())
return
if len(key) == 44 and key.endswith("="):
_fernet = Fernet(key.encode())
else:
import base64
import hashlib
derived = hashlib.sha256(key.encode()).digest()
_fernet = Fernet(base64.urlsafe_b64encode(derived))
def encrypt_api_key(plaintext: str) -> bytes:
if _fernet is None:
raise RuntimeError("Encryption not initialized. Call init_encryption() first.")
return _fernet.encrypt(plaintext.encode())
def decrypt_api_key(ciphertext: bytes) -> str:
if _fernet is None:
raise RuntimeError("Encryption not initialized. Call init_encryption() first.")
return _fernet.decrypt(ciphertext).decode()