@freedomofpress/webcat
    Preparing search index...

    Class WebcatDatabase

    A Database backed by a NamespacedKVStore.

    Hierarchy (View Summary)

    Implements

    Index
    • Parameters

      • config: { namespace: string; nonOriginCacheSize: number; originCacheSize: number }
        • namespace: string

          A string prefix used for all persisted keys.

        • nonOriginCacheSize: number

          The number of hostnames to store in-memory in the negative origin cache.

        • originCacheSize: number

          The number of OriginState objects to cache locally.

      Returns WebcatDatabase

    enrollments: NamespacedKVStore = ...

    A subnamespace for storing enrollment hashes.

    A partitioned LRU set of fully-qualified domain names not enrolled in WEBCAT.

    A partitioned LRU cache of origin states.

    • Clears all values whose key matches the specified prefix.

      Parameters

      • prefix: string = ""

        The prefix to match against.

      • area: "local" | "session" = "local"

        The name of the storage area to use.

      Returns Promise<void>

    • Reads a persisted value.

      Parameters

      • key: string

        The key to read.

      • area: "local" | "session" = "local"

        The name of the storage area to read from.

      Returns Promise<any>

      A Promise that resolves to the value read.

    • Reads an enrollment hash from the database.

      Parameters

      • fqdn: string

        The fully-qualified domain name whose enrollment hash to read.

      • cachePartition: CachePartition

        The cache partition to use for cache lookups.

      Returns Promise<Uint8Array<ArrayBufferLike>>

      A Promise that resolves to the locally persisted enrollment hash corresponding to fqdn.

    • Retrieves a list of stored keys matching the specified prefix.

      Parameters

      • prefix: string = ""

        The prefix to match against.

      • area: "local" | "session" = "local"

        The name of the storage area to read from.

      Returns Promise<string[]>

      A Promise that resolves to an array of matching keys.

    • Reads the timestamp of the most recent enrollment update attempt.

      Returns Promise<number | null>

      A Promise that resolves to a time in milliseconds.

    • Reads the timestamp of the most recent successful enrollment update.

      Returns Promise<number | null>

      A Promise that resolves to a time in milliseconds.

    • Reads fully-qualified domain names of enrolled origins from the database.

      Returns Promise<string[]>

      A Promise that resolves to an array of the FQDNs whose enrollment is persisted locally.

    • Clears a single persisted value.

      Parameters

      • key: string

        The key to clear.

      • Optionalarea: "local" | "session"

        The name of the storage area to use.

      Returns Promise<void>

    • Stores values.

      Parameters

      • items: { [key: string]: unknown }

        An object consisting of one or more key/value pairs to store.

      • area: "local" | "session" = "local"

        The name of the storage area to use.

      Returns Promise<void>

    • Persists current time as the time of the latest enrollment update attempt.

      Returns Promise<void>

    • Persists the current time as the time of the latest successful enrollment update.

      Returns Promise<void>

    • Updates the list of enrolled fully-qualified domain names.

      Parameters

      • leaves: readonly (readonly [string, string])[]
      • meta: BlockMeta

      Returns Promise<void>