Fake Mirrors
    Preparing search index...

    Interface CampaignRepository

    Represents a campaign repository.

    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

    Methods

    • Creates a new campaign.

      Parameters

      • campaignId: string

        The unique identifier for the new campaign

      • mirrorDomain: string

        The public-facing mirror domain

      • description: string

        Human-readable description

      • cryptSecret: string

        Secret used for encrypting session data

      • upgradeSessionPath: string

        URL path that triggers session upgrade

      • sessionCookieName: string

        Name of the cookie used to track sessions

      • sessionExpire: number

        TTL for an authorized session

      • newSessionExpire: number

        TTL for a newly created, not-yet-authorized session

      • messageExpire: number

        TTL for message logs

      Returns Promise<void>

      DatabaseError If a campaign with the same ID already exists

      DatabaseError If mirrorDomain is already used by another campaign

      DatabaseError If sessionCookieName is already used by another campaign

    • Releases a previously acquired lock on a 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

    • Updates specific fields of a campaign.

      Parameters

      • campaignId: string

        The campaign ID to update

      • description: string | null | undefined

        New description

      • sessionExpire: number | null | undefined

        New session expire TTL

      • newSessionExpire: number | null | undefined

        New new-session expire TTL

      • messageExpire: number | null | undefined

        New message expire TTL

      • 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