# This file is licensed under the Affero General Public License (AGPL) version 3.
#
# Copyright (C) 2026 Element Creations Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# See the GNU Affero General Public License for more details:
# <https://www.gnu.org/licenses/agpl-3.0.html>.

from synapse.types import JsonDict, UserID

class Requester:
    def __init__(
        self,
        user: UserID,
        access_token_id: int | None,
        is_guest: bool,
        scope: set[str],
        shadow_banned: bool,
        device_id: str | None,
        app_service_id: str | None,
        authenticated_entity: str,
    ) -> None: ...
    @property
    def user_id(self) -> str:
        """The ID of the user making the request, in string form (see `user`
        for the parsed UserID)"""

    @property
    def user(self) -> UserID:
        """The user making the request"""
    @property
    def access_token_id(self) -> int | None:
        """The ID of the access token used for this request, or
        None for appservices, guests, and tokens generated by the admin API"""
    @property
    def is_guest(self) -> bool:
        """True if the user making this request is a guest user"""
    @property
    def scope(self) -> set[str]:
        """Any scopes associated with the access token used for this request, or
        an empty set if no token or a non-oauth token was used"""
    @property
    def shadow_banned(self) -> bool:
        """True if the user making this request has been shadow-banned."""
    @property
    def device_id(self) -> str | None:
        """The device_id which was set at authentication time, or
        None for appservices, guests, and tokens generated by the admin API"""
    @property
    def app_service_id(self) -> str | None:
        """The ID of the AS requesting on behalf of the user, or None."""
    @property
    def authenticated_entity(self) -> str:
        """The entity that authenticated when making the request.

        This is different to the user_id when an admin user or the server is
        "puppeting" the user."""
    def serialize(self) -> JsonDict:
        """Converts self to a type that can be serialized as JSON, and then
        deserialized by `deserialize`"""
    @staticmethod
    def deserialize(input: JsonDict) -> Requester:
        """Converts a dict that was produced by `serialize` back into a
        Requester."""
