New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

webext-agent

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webext-agent

An agent to enable remote WebExtensions APIs for browsers

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

webext-agent

The webext-agent is a browser extension that enables remote access to WebExtensions APIs. It helps you for automating browser integration and testing.

Installation

Install by npm:

$ npm install --save webext-agent  # npm
$ yarn add webext-agent            # yarn
$ pnpx webext-agent install        # pnpm

Preparation

The webext-agent access the browser via native messaging. It requires a native messaging manifest to be installed to the local. The webext-agent does not install the manifest automatically due to the security reason. You can install it manually by the following command:

$ webext-agent install --addon-ids my-addon1@example.com,my-addon2@example.com,...

Quick start

Create a new agent add-on:

$ webext-agent create-addon \
    --additional-permissions tabs \
    --addon-id my-addon@example.com
    /tmp/my-agent-addon

and load it via about:config on your Firefox browser. The agent server starts and you can access APIs by the following JavaScript/TypeScript:

const { connect } = require("webext-agent");

(async () => {
  const browser = await connect("my-addon@example.com");
  const tabs = await browser.tabs.query({});

  tabs.forEach((tab) => {
    console.log("[%d] %s - %s", tab.id, tab.title, tab.url)
  })
})();

CLI

install

Install a native messaging manifest to the local

$ webext-agent install --addon-ids my-addon1@example.com,my-addon2@example.com,...

uninstall

Uninstall the installed native messaging manifest from the local.

$ webext-agent uninstall

check

Check if the native message manifest is installed.

$ webext-agent install

create-addon

Create a new agent add-on.

$ webext-agent create-addon \
    --additional-permissions <permission1>,<permission2>,... \
    --addon-id <addon-id> \
    [--base-addon <base-addon>] \
    <destination>

You can mix-in an agent add-on with your add-ons by --base-addon option. This is useful to debug or access the internal storage on your add-on.

JavaScript/TypeScript API

webext-agent also provides programmatic APIs.

createAgentAddon(destination[, options])

  • destination Destination directory to create an agent add-on.
  • options
    • additionalPermissions Additional permissions to be added to the add-on.
import { createAgentAddon } from "webext-agent";

const addon = await createAgentAddon("/tmp/my-agent-addon");

console.log(addon.getRoot());

createMixedInAgentAddon(baseAddon, destination[, options])

  • baseAddon The directory location containing a base add-on.
  • destination Destination directory to create an agent add-on.
  • options
    • additionalPermissions Additional permissions to be added to the add-on.
    • addonId An id of the Addon
import { createMixedInAgentAddon } from "webext-agent";

const addon = await createMixedInAgentAddon("path/to/your/addon", "/tmp/my-new-addon");

console.log(addon.getRoot());

connect()

  • address The address and port the client connect to, address:port in a string, or in a object containing address in a string and port in a number.
import { connect } from "webext-agent";

const browser = await connect("127.0.0.1:12345");
const tabs = await browser.tabs.query({});

console.log(tabs);

LICENSE

MIT

FAQs

Package last updated on 28 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts