            "webRequest.onAuthRequired"
          );
          parentEvent.addListener(listener, filter, extra);
          return () => {
            parentEvent.removeListener(listener);
          };
        },
      }).api(),
    };

    // For extensions with manifest_version >= 3, an additional webRequestFilterResponse permission
    // is required to get access to the webRequest.filterResponseData API method.
    if (
      context.extension.manifestVersion < 3 ||
      context.extension.hasPermission("webRequestFilterResponse")
    ) {
      webRequest.filterResponseData = filterResponseData;
    } else {
      webRequest.filterResponseData = () => {
        throw new ExtensionError(
          'Missing required "webRequestFilterResponse" permission'
        );
      };
    }

    return { webRequest };
  }
};
PK