Fake Mirrors
    Preparing search index...

    Interface ProxyRepository

    Defines the public contract for a proxy repository.

    A proxy contains an upstream server that handles outgoing traffic. Proxies are automatically load-balanced when creating and authorizing sessions.

    interface ProxyRepository {
        create(
            campaignId: string,
            proxyId: string,
            url: string,
            lockSecret: string,
        ): Promise<void>;
        delete(
            campaignId: string,
            proxyId: string,
            lockSecret: string,
        ): Promise<void>;
        disable(
            campaignId: string,
            proxyId: string,
            lockSecret: string,
        ): Promise<void>;
        enable(
            campaignId: string,
            proxyId: string,
            lockSecret: string,
        ): Promise<void>;
        list(campaignId: string): Promise<ProxyModel[] | null>;
        read(campaignId: string, proxyId: string): Promise<ProxyModel | null>;
    }

    Implemented by

    • Creates a new proxy.

      The proxy will be created in a disabled state (isEnabled = false). Use enable to activate it for traffic routing.

      Parameters

      • campaignId: string

        The ID of the campaign to create the proxy in.

      • proxyId: string

        The new proxy ID to create.

      • url: string

        The upstream URL for the proxy.

      • lockSecret: string

        The campaign lock secret obtained from CampaignRepository.lock.

      Returns Promise<void>

      DatabaseError If the campaign does not exist.

      DatabaseError If the campaign is not locked.

      DatabaseError If the campaign lock secret does not match.

      DatabaseError If a proxy with the same ID already exists.

      DatabaseError If the proxy URL is already used.

      DatabaseError If the data validation fails.

    • Deletes the proxy by its ID.

      A proxy must be disabled before it can be deleted.

      Parameters

      • campaignId: string

        The ID of the campaign containing the proxy.

      • proxyId: string

        The proxy ID to delete.

      • lockSecret: string

        The campaign lock secret obtained from CampaignRepository.lock.

      Returns Promise<void>

      DatabaseError If the campaign does not exist.

      DatabaseError If the campaign is not locked.

      DatabaseError If the campaign lock secret does not match.

      DatabaseError If the proxy does not exist.

      DatabaseError If the proxy is still enabled.

      DatabaseError If the data validation fails.

    • Disables the proxy, stopping traffic routing.

      Existing sessions using this proxy will be automatically re-assigned to another enabled proxy upon their next authorization.

      Parameters

      • campaignId: string

        The ID of the campaign containing the proxy.

      • proxyId: string

        The proxy ID to disable.

      • lockSecret: string

        The campaign lock secret obtained from CampaignRepository.lock.

      Returns Promise<void>

      DatabaseError If the campaign does not exist.

      DatabaseError If the campaign is not locked.

      DatabaseError If the campaign lock secret does not match.

      DatabaseError If the proxy does not exist.

      DatabaseError If the data validation fails.

    • Enables the proxy, making it available for traffic routing.

      Enabled proxies are automatically selected by the session creation logic using random load balancing.

      Parameters

      • campaignId: string

        The ID of the campaign containing the proxy.

      • proxyId: string

        The proxy ID to enable.

      • lockSecret: string

        The campaign lock secret obtained from CampaignRepository.lock.

      Returns Promise<void>

      DatabaseError If the campaign does not exist.

      DatabaseError If the campaign is not locked.

      DatabaseError If the campaign lock secret does not match.

      DatabaseError If the proxy does not exist.

      DatabaseError If the data validation fails.

    • Lists all proxies for the campaign.

      Proxies are ordered by creation time (oldest first).

      Parameters

      • campaignId: string

        The ID of the campaign to list proxies for.

      Returns Promise<ProxyModel[] | null>

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

      DatabaseError If the data validation fails.

    • Reads the proxy by its ID.

      Parameters

      • campaignId: string

        The ID of the campaign containing the proxy.

      • proxyId: string

        The proxy ID to read.

      Returns Promise<ProxyModel | null>

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

      DatabaseError If the data validation fails.