Fake Mirrors
    Preparing search index...

    Interface CampaignRepository

    Defines the public contract for a campaign repository.

    A campaign is the top-level container that groups all related proxies, targets, redirectors, lures, sessions and messages.

    interface CampaignRepository {
        appendFlag(campaignId: string, flag: string): Promise<void>;
        create(
            campaignId: string,
            mirrorDomain: string,
            description: string,
            cryptSecret: string,
            upgradeSessionPath: string,
            sessionCookieName: string,
            sessionExpire: number,
            newSessionExpire: number,
            messageExpire: number,
        ): Promise<void>;
        delete(campaignId: string, lockSecret: string): Promise<void>;
        list(): Promise<CampaignModel[]>;
        listFull(): Promise<FullCampaignModel[]>;
        lock(campaignId: string): Promise<string>;
        read(campaignId: string): Promise<CampaignModel | null>;
        readFull(campaignId: string): Promise<FullCampaignModel | null>;
        removeFlag(campaignId: string, flag: string): Promise<void>;
        unlock(campaignId: string, lockSecret: string): Promise<void>;
        update(
            campaignId: string,
            description: string,
            sessionExpire: number,
            newSessionExpire: number,
            messageExpire: number,
            lockSecret: string,
        ): Promise<void>;
    }

    Implemented by

    • Appends named flag to the campaign.

      Parameters

      • campaignId: string

        The ID of the campaign.

      • flag: string

        The flag to append to the campaign.

      Returns Promise<void>

      DatabaseError If the campaign does not exist.

      DatabaseError If the data validation fails.

    • Creates a new campaign.

      Parameters

      • campaignId: string

        The new campaign ID to create.

      • mirrorDomain: string

        The public-facing mirror domain for the campaign.

      • description: string

        The human-readable description for the campaign.

      • cryptSecret: string

        The secret used for encrypting session data.

      • upgradeSessionPath: string

        The URL path that triggers session upgrade.

      • sessionCookieName: string

        The name of the cookie used to track authorized sessions.

      • sessionExpire: number

        The TTL for an authorized session in milliseconds.

      • newSessionExpire: number

        The TTL for a not-yet-authorized session in milliseconds.

      • messageExpire: number

        The TTL for a message in milliseconds.

      Returns Promise<void>

      DatabaseError If a campaign with the same ID already exists.

      DatabaseError If the mirror domain is already used by another campaign.

      DatabaseError If the session cookie name is already used by another campaign.

      DatabaseError If the data validation fails.

    • Deletes the campaign by its ID.

      Parameters

      • campaignId: string

        The campaign ID to delete.

      • lockSecret: string

        The lock secret obtained from lock.

      Returns Promise<void>

      DatabaseError If the campaign does not exist.

      DatabaseError If the campaign is not locked.

      DatabaseError If the lock secret does not match.

      DatabaseError If the campaign still has associated entities.

      DatabaseError If the data validation fails.

    • Lists all campaigns.

      The campaigns are ordered by creation time (oldest first).

      Returns Promise<CampaignModel[]>

      The array of campaign models.

      DatabaseError If the data validation fails.

    • Lists all full campaigns.

      The campaigns are ordered by creation time (oldest first).

      Returns Promise<FullCampaignModel[]>

      The array of full campaign models.

      DatabaseError If the data validation fails.

    • Acquires a distributed lock for the campaign.

      This lock is required for any mutating operations.

      Parameters

      • campaignId: string

        The campaign ID to lock.

      Returns Promise<string>

      The unique lock secret that must be used for subsequent operations.

      DatabaseError If the campaign does not exist.

      DatabaseError If the campaign is already locked.

      DatabaseError If the data validation fails.

    • Reads the campaign by its ID.

      Parameters

      • campaignId: string

        The campaign ID to read.

      Returns Promise<CampaignModel | null>

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

      DatabaseError If the data validation fails.

    • Reads the full campaign by its ID.

      Parameters

      • campaignId: string

        The campaign ID to read.

      Returns Promise<FullCampaignModel | null>

      The full campaign model, or null if the campaign is not found.

      DatabaseError If the data validation fails.

    • Removes named flag from the campaign.

      Parameters

      • campaignId: string

        The ID of the campaign.

      • flag: string

        The flag to remove to the campaign.

      Returns Promise<void>

      DatabaseError If the campaign does not exist.

      DatabaseError If the data validation fails.

    • Releases a previously acquired lock on the campaign.

      The lock secret must match the one returned by lock.

      Parameters

      • campaignId: string

        The campaign ID to unlock.

      • lockSecret: string

        The lock secret returned by the lock.

      Returns Promise<void>

      DatabaseError If the campaign does not exist.

      DatabaseError If the lock secret does not match.

      DatabaseError If the data validation fails.

    • Updates the campaign specific fields.

      Parameters

      • campaignId: string

        The campaign ID to update.

      • description: string

        The new human-readable description for the campaign.

      • sessionExpire: number

        The new TTL for an authorized session in milliseconds.

      • newSessionExpire: number

        The new TTL for a not-yet-authorized session in milliseconds.

      • messageExpire: number

        The new TTL for a message in milliseconds.

      • lockSecret: string

        The lock secret obtained from lock.

      Returns Promise<void>

      DatabaseError If the campaign does not exist.

      DatabaseError If the campaign is not locked.

      DatabaseError If the lock secret does not match.

      DatabaseError If the data validation fails.