npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

webext-buildtools-firefox-addons-builder

v2.2.0

Published

webext-buildtools builder for deploying to Firefox Addons store and signing xpi files

Downloads

43

Readme

npm-publish

Introduction

webext-buildtools builder which allows you to deploy extension (packed to zip) to Firefox Addons, and sign xpi file (for offline distribution).

Installation

npm install webext-buildtools-firefox-addons-builder

Purpose

Builder uses Firefox Addons API to deploy your extension and/or get signed crx file for offline distribution (read "Signing and distributing your add-on" for details).

Builder doesn't allow to publish new extension, only update existing (deploy.extensionId in options) with new version.

Usage example

const FirefoxAddonsBuilder = require('webext-buildtools-firefox-addons-builder').default;
const fs = require('fs-extra');

const options = { ... }; // see description below
const logMethod = console.log;
const builder = new FirefoxAddonsBuilder(options, logMethod);

// Optional, can be extracted from zip
builder.setInputManifest(await fs.readJson('./ext_dir/package.json'));
builder.setInputZipBuffer(await fs.read('./packed.zip'));

builder.requireDeployedExt();
builder.requireSignedXpiFile();

const buildResult = await builder.build();

Options

Options object described in declarations/options.d.ts

See how to get logMethod for pretty output.

Api access

To set up API access you need to generate and specify jwtIssuer, jwtSecret in options.api. You can create them at https://addons.mozilla.org/en-US/developers/addon/api/key/

Inputs

🔸 extension zip archive; Required

Can be set using one of the following inputs:

1. setInputZipBuffer(buffer: Buffer)

Buffer with zipped extension dir.

2. setInputZipFilePath(filePath: string)

Buffer with zipped extension dir.

3. setInputUploadId(uploadId: string) Only for "Deployed extension" output

Id of existing upload. Can be used if uploading succeeded at the previous try, but polling failed by timeout and version hasn't been published.

🔹 setInputManifest(...) Only for "Signed xpi" output

Object with parsed extension's package.json. Will be extracted from zip if not specified.

🔹 sources archive

It's needed for admins for a review if your zipped extension contains minified code. Can be set using one of the following inputs:

1. setInputSourcesZipBuffer(buffer: Buffer)

Buffer with zipped dir containing source code of the extension.

2. setInputSourcesZipFilePath(filePath: string)

Path to zip containing source code of the extension.

You can use webext-buildtools-dir-reader-mw to generate needed inputs from extension directory.

Outputs

Deployed extension

Require to deploy extension to Firefox Addons

Required options: deploy.extensionId, api Require methods: requireSignedXpiFile() Assets: const xpiFilePath = buildResult.getAssets().signedXpiFile.getValue() const xpiBuffer = buildResult.getAssets().signedXpiBuffer.getValue() const extId = buildResult.getAssets().signedExtStoreId.getValue()

Signed xpi file

Require to get signed xpi file. This output is independent of deployed extension. options.signXpi.extensionId should contain id of extension uploaded to Firefox Addons especially for offline distribution. If not specified, new extension will be added for every build (not recommended)

Required options: signXpi.extensionId (recommended), signXpi.xpiOutPath (if not temporary file required), apiAccess

Require methods: requirePublishedExt() Assets: const extId = buildResult.getAssets().deployedExtStoreId.getValue()

Errors

Package exports the following error classes, which can be thrown:

  • VersionAlreadyExistsError if you try to upload already existing version
  • UnauthorizedError: For "Deployed extension" output. jwtIssuer, jwtSecret Options are invalid.
  • ValidationError For "Deployed extension" output. Firefox Addons validation rejected your extension
  • PollTimedOutError For "Deployed extension" output. Polling uploaded item status was timed out. Your extension will be probably published later.
  • RequestThrottled API request were declined because you reached the request frequency limit.

All these custom errors have AddonsApiError base class that contain the following properties:

  • version: string|undefined: extension version if known at the moment error occurred
  • uploadId: string|undefined: id of upload if known at the moment error occurred

References

If you are interested in building CI/CD solution for Web Extension using GitHub Actions it's better to use the dedicated actions for it instead.

Please read the "Releasing WebExtension using GitHub Actions" article to learn the details.

If you need to deploy to other targets, take a look at webext-buildtools-integrated-builder repo.

To read what are webext-buildtools and builders go to webext-buildtools-builder-types repo.

sign-addon package is used for signing under the hood.