Fake Mirrors
    Preparing search index...

    Interface SessionRepository

    Defines the public contract for a session repository.

    A session tracks a user's interaction with the mirror, including their assigned proxy, upgrade status, and message count.

    interface SessionRepository {
        auth(campaignId: string, sessionId: string): Promise<SessionModel>;
        create(campaignId: string): Promise<SessionModel>;
        list(campaignId: string, limit: number): Promise<SessionModel[] | null>;
        read(campaignId: string, sessionId: string): Promise<SessionModel | null>;
        revoke(campaignId: string, sessionId: string): Promise<void>;
        upgrade(
            campaignId: string,
            lureId: string,
            sessionId: string,
            secret: string,
        ): Promise<void>;
    }

    Implemented by

    • Authorizes the session by its ID.

      If the session proxy is disabled, re-assigns it to a random enabled proxy.

      Parameters

      • campaignId: string

        The ID of the campaign containing the session.

      • sessionId: string

        The session ID to authorize.

      Returns Promise<SessionModel>

      The authorized session model.

      DatabaseError If the campaign does not exist.

      DatabaseError If the session does not exist.

      DatabaseError If the session is revoked.

      DatabaseError If no enabled proxies are available.

      DatabaseError If the data validation fails.

    • Creates a new session.

      The session is automatically assigned to a random enabled proxy.

      Parameters

      • campaignId: string

        The ID of the campaign to create the session in.

      Returns Promise<SessionModel>

      The newly created session model.

      DatabaseError If the campaign does not exist.

      DatabaseError If no enabled proxies are available.

      DatabaseError If the data validation fails.

    • Lists campaign session history.

      Sessions are ordered by auth time (newest first).

      Parameters

      • campaignId: string

        The ID of the campaign to list sessions for.

      • limit: number

        Limit on the number of records.

      Returns Promise<SessionModel[] | null>

      The array of session models, or null if the campaign does not exist.

      DatabaseError If the data validation fails.

    • Reads the session by its ID.

      Parameters

      • campaignId: string

        The ID of the campaign containing the session.

      • sessionId: string

        The session ID to read.

      Returns Promise<SessionModel | null>

      The session model, or null if the session is not found.

      DatabaseError If the data validation fails.

    • Revoking a session and stopping authorization.

      Parameters

      • campaignId: string

        The ID of the campaign containing the session.

      • sessionId: string

        The session ID to revoke.

      Returns Promise<void>

      DatabaseError If the campaign does not exist.

      DatabaseError If the session does not exist.

      DatabaseError If the data validation fails.

    • Upgrades the session by its ID and secret.

      Parameters

      • campaignId: string

        The ID of the campaign containing the session.

      • lureId: string

        The Lure ID through which the session is upgraded.

      • sessionId: string

        The session ID to upgrade.

      • secret: string

        The session secret.

      Returns Promise<void>

      DatabaseError If the campaign does not exist.

      DatabaseError If the lure does not exist.

      DatabaseError If the session does not exist.

      DatabaseError If the secret does not match.

      DatabaseError If the session is revoked.

      DatabaseError If the data validation fails.