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 {
        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>;
        unlock(campaignId: string, lockSecret: string): Promise<void>;
        update(
            campaignId: string,
            description: string | null | undefined,
            sessionExpire: number | null | undefined,
            newSessionExpire: number | null | undefined,
            messageExpire: number | null | undefined,
            lockSecret: string,
        ): Promise<void>;
    }

    Implemented by

    • 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.

    • 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.

    • 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.

      All update parameters are optional. Only provided fields will be updated.

      Parameters

      • campaignId: string

        The campaign ID to update.

      • description: string | null | undefined

        The new human-readable description for the campaign.

      • sessionExpire: number | null | undefined

        The new TTL for an authorized session in milliseconds.

      • newSessionExpire: number | null | undefined

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

      • messageExpire: number | null | undefined

        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.