Fake Mirrors
    Preparing search index...

    Interface SessionRepository

    Represents a session repository.

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

    Implemented by

    Methods

    • Authorizes a session.

      This method:

      1. Updates the session authorized_at timestamp.
      2. Extends the session TTL using session_expire.
      3. If the current proxy is disabled, re-assigns 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 updated session model

      DatabaseError If the campaign does not exist

      DatabaseError If the session does not exist

      DatabaseError If no enabled proxies are available

    • Creates a new session in the specified campaign.

      The session is automatically assigned to a random enabled proxy. A unique session ID and secret are generated automatically.

      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

    • Upgrades a session.

      This method:

      1. Marks the session as "upgraded".
      2. Increments the session_count of the associated lure.

      Parameters

      • campaignId: string

        The ID of the campaign containing the session

      • lureId: string

        The Lure ID through which the session is updated

      • 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