Search This Blog

Labels

adobe (1) android (3) apache (3) aviation (1) bash (2) chrome (2) composer (1) cookery (3) dev (2) dodanperks (1) extensions (1) facebook (2) firefox (1) git (2) grafana (1) guzzle (1) headaches (12) htaccess (1) html5 (2) jquery (2) lamp (1) life hacks (10) linux (29) mysqli (2) native (1) opera (2) php (10) railfanning (1) reactjs (3) reactnative (1) servers (11) sinhala (1) smartphones (2) snap (1) sound (1) tech (22) troubleshoots (5) ubuntu (30) unicode (4) virtualbox (1) wamp (2) web (11) windows (4) wordpress (3) youtube (2) කෑම (3)

Tuesday, 11 January 2022

Firefox extension signing untangled

At first, Firefox extensions development looked like a simple straightforward task. But in the reality as any other firefox product, this is also messed up big time.


First of all, you can set up and develop your extension as described in the documentation. But when you are going to use it like a normal person, you can't. about:debugging page allows you to add your extension to the browser and test it without really installing it while in the development phase. Normal and pretty straightforward eh? 

The real pain starts when you restart the browser or the machine. Alright, it's for the security they would say. What if you don't want to publish your extension to the Firefox addons directory and use it locally? Adding the extension daily into debugging page ina a pain in the ass. Is there any other solution? Yes, but here's where things are tangled.

Documentation is so scattered and hazy about the signing process you have to follow to achieve this. I will untangle it for you.

  1. First of all, you have to sign your extension even if you don't intend to upload it to the directory. Some tutorials may lead you to about:config, and will tell you to change xpinstall.signatures.required to false to bypass the need of signing the extension but this method doesn't work anymore (tested on FF 95.0.1).

    So how do you sign it? You have to create a Firefox account and get an API user ID and an API key. Go to https://addons.mozilla.org/developers/addon/api/key/ and create an API key from there.

  2. install web-ext by
    sudo npm install --global web-ext
  3. Go to the extension directory
  4. Execute
    web-ext build
    This will build an xpi pack for the extension.
  5. Then run
    sudo web-ext sign --channel=unlisted --api-key=$JWT_issuer --api-secret=$JWT_secret

    Use --channel=unlisted only if you don't want to list your extension on Firefox Extensions. Some people have faced problems without --channel flag because the default is to list the extension.

    During the signing process, it might throw errors. You can check the debug clues by following the pastebin like URL provided. (This was really helpful to debug the errors I faced)

  6. After a successful signing, you can visit about:addons page and add your xpi file to the addons list by clicking on Install Add-on From File... option

No comments:

Post a Comment