@freedomofpress/webcat
    Preparing search index...

    Class PermissionChecker

    Checks extension permissions and triggers warnings for missing ones. For an example, PermissionChecker.require.

    Hierarchy

    • EventTarget
      • PermissionChecker
    Index
    addEventListener: (
        type: string,
        callback: EventListenerOrEventListenerObject | null,
        options?: boolean | AddEventListenerOptions,
    ) => void & (
        type: "permissionerror",
        callback: (event: PermissionErrorEvent) => void,
    ) => void & (
        type: "permissionrestored",
        callback: (event: PermissionRestoredEvent) => 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

    • Checks the permissions of a given subject.

      Parameters

      • subject: Subject

        The subject of the permissions.

      Returns Promise<boolean>

      A Promise that resolves to true if the subject has all the permissions required.

    • 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

    • Reads the missing permissions for a subject. If subject is omitted, reads the missing permissions across all subjects.

      Parameters

      • Optionalsubject: Subject

        The subject of the permissions.

      Returns Set<string>

      The set of missing permissions required by the subject via require, or if no subject is given, missing permissions across all subjects.

    • Reads the required permissions for a subject. If subject is omitted, reads the required permissions across all subjects.

      Parameters

      • Optionalsubject: Subject

        The subject of the permissions.

      Returns Set<string>

      The set of permissions declared for the subject via require, or if no subject is given, permissions across all subjects.

    • 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

    • Creates a decorator that checks for an extension permission. For a class or method that requires multiple permissions, use multiple decorators.

      Permissions are checked at declaration time, not at instantiation or call time. Permission checks are asynchronous, best-effort, and do not block any code from running.

      Permission warnings in the console may be suppressed by calling PermissionErrorEvent.preventDefault.

      Parameters

      Returns (subject: Subject) => void

      import permissions from "@freedomofpress/webcat/browser/permissions";

      @permissions.require("webRequest")
      @permissions.require("webRequestBlocking")
      @permissions.require("https://example.com/*")
      class ExampleBlocker {
      ...
      }