Fake Mirrors
    Preparing search index...

    Interface LureRepository

    Defines the public contract for a lure repository.

    A lure contains a URL path endpoint that maps incoming HTTP requests to a redirector. Lures are created in a disabled state and must be explicitly enabled to start routing traffic.

    interface LureRepository {
        create(
            campaignId: string,
            lureId: string,
            path: string,
            redirectorId: string,
            lockSecret: string,
        ): Promise<void>;
        delete(
            campaignId: string,
            lureId: string,
            redirectorId: string,
            lockSecret: string,
        ): Promise<void>;
        disable(
            campaignId: string,
            lureId: string,
            lockSecret: string,
        ): Promise<void>;
        enable(
            campaignId: string,
            lureId: string,
            lockSecret: string,
        ): Promise<void>;
        find(campaignId: string, path: string): Promise<LureModel | null>;
        list(campaignId: string): Promise<LureModel[] | null>;
        read(campaignId: string, lureId: string): Promise<LureModel | null>;
    }

    Implemented by

    • Creates a new lure.

      The lure 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 lure in.

      • lureId: string

        The new lure ID to create.

      • path: string

        The URL path for the lure.

      • redirectorId: string

        The ID of the redirector that handles this lure.

      • 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 lure with the same ID already exists.

      DatabaseError If the lure URL path is already used by another campaign.

      DatabaseError If the redirector does not exist.

      DatabaseError If the data validation fails.

    • Deletes the lure by its ID.

      A lure must be disabled before it can be deleted.

      Parameters

      • campaignId: string

        The ID of the campaign containing the lure.

      • lureId: string

        The lure ID to delete.

      • redirectorId: string

        The ID of the redirector that handles this lure.

      • 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 lure does not exist.

      DatabaseError If the redirector does not exist.

      DatabaseError If the lure is still enabled.

      DatabaseError If the lure redirector ID does not match the provided one.

      DatabaseError If the data validation fails.

    • Disables the lure, stopping request routing.

      When disabled, requests to the URL path will not be routed.

      Parameters

      • campaignId: string

        The ID of the campaign containing the lure.

      • lureId: string

        The lure 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 lure does not exist.

      DatabaseError If the data validation fails.

    • Enables the lure, making it available for request routing.

      When enabled, the URL path becomes active and can be used to serve the associated redirector content.

      Parameters

      • campaignId: string

        The ID of the campaign containing the lure.

      • lureId: string

        The lure 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 lure does not exist.

      DatabaseError If the data validation fails.

    • Finds a lure by its URL path.

      This is the primary routing method for HTTP requests. When a request arrives at a mirror domain, the request path is extracted and used to instantly find the corresponding lure via a direct hash lookup.

      Parameters

      • campaignId: string

        The ID of the campaign to search in.

      • path: string

        The URL path to look up.

      Returns Promise<LureModel | null>

      The lure model, or null if no lure matches the URL path.

      DatabaseError If the data validation fails.

    • Lists all lures for the campaign.

      Lures are ordered by creation time (oldest first).

      Parameters

      • campaignId: string

        The ID of the campaign to list lures for.

      Returns Promise<LureModel[] | null>

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

      DatabaseError If the data validation fails.

    • Reads the lure by its ID.

      Parameters

      • campaignId: string

        The ID of the campaign containing the lure.

      • lureId: string

        The lure ID to read.

      Returns Promise<LureModel | null>

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

      DatabaseError If the data validation fails.