@freedomofpress/webcat
    Preparing search index...

    Class EnrollmentUpdater

    Handles loading enrollment updates periodically from the endpoint, storing them to the database, and notifying event consumers.

    Hierarchy

    • EventTarget
      • EnrollmentUpdater
    Index
    DefaultCheckInterval: number = ...

    The default value for EnrollmentUpdaterConfig.checkInterval, 5 minutes.

    DefaultFetchTimeout: 3000

    The default value for EnrollmentUpdaterConfig.fetchTimeout, 3 seconds.

    DefaultUpdateInterval: number = ...

    The default value for EnrollmentUpdaterConfig.updateInterval, 1 hour.

    addEventListener: (
        type: string,
        callback: EventListenerOrEventListenerObject | null,
        options?: boolean | AddEventListenerOptions,
    ) => void & (
        type: "updated",
        callback: (event: UpdateEvent) => void,
    ) => void

    Type Declaration

      • (
            type: string,
            callback: EventListenerOrEventListenerObject | null,
            options?: boolean | AddEventListenerOptions,
        ): void
      • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

        MDN Reference

        Parameters

        • type: string
        • callback: EventListenerOrEventListenerObject | null
        • Optionaloptions: boolean | AddEventListenerOptions

        Returns void

      • (type: "updated", callback: (event: UpdateEvent) => void): void
      • Parameters

        • type: "updated"
        • callback: (event: UpdateEvent) => void

        Returns void

    • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().

      MDN Reference

      Parameters

      • event: Event

      Returns boolean

    • Determines whether an update is due.

      Returns Promise<boolean>

      A Promise that resolves to true if an update is due.

    • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject | null
      • Optionaloptions: boolean | EventListenerOptions

      Returns void

    • Retries an update if the previous attempt failed. Unlike update, retryIfFailed never throws.

      Returns Promise<void>

    • Loads bundled enrollments and initiates periodic updates.

      Returns void

    • Immediately does a single update. If local is true, only the enrollment files bundled with the extension are consulted without accessing the network.

      Parameters

      • local: boolean = false

      Returns Promise<void>