Firefox Add-On ID Conventions
Asked Answered
N

1

5

I'm writing a Firefox Add-On using the WebExtension API. Some of the APIs (such as browser.storage.sync) require an Add-On ID to be explicitly declared in the add-on's manifest.json file.

The documentation for IDs states:

The ID of the extension, which must be one of the following:

The latter format is significantly easier to generate and manipulate. Firefox 1.5 has checking to ensure that your id falls into one format or the other and will refuse to install add-ons that have malformed ids. You should not use a real email address for your id, however, as it might attract spam.

The documentation is not very clear with regards to what kind of string I can provide. Is it...

  • Any valid email address?
  • Any string that "looks like" [email protected]?
  • How about [email protected]?
  • Should it be relevant to the extension itself?
  • Should it have a domain name I own or can it be any?

etc.

Because I must declare the ID explicitly to use browser.storage.sync, I am unable to depend on the automatic ID that can be provided by Firefox for WebExtensions.

What are the conventions for explicitly declared add-on IDs in Firefox?

Neysa answered 27/7, 2017 at 0:33 Comment(6)
well, the documentation states [email protected] as for your question Any valid email address? - the documentation you quoted says You should not use a real email address for your id, however, as it might attract spam - so, a valid email address format but don't use a real email address - the point of using your domain (in the example it's example.org) is that someone else is not likely to do so ... if you pick a random [email protected] ... what's to say that isn't already used by someone else?Farny
having said all that, you do know that add-on wont work in firefox 57+ and in fact you won't be able to submit it to addons.mozilla.org anyway, since firefox 53 is already old :pFarny
That's my question: "how do I not know it's in use by someone else?" I don't necessarily own a domain name.Neysa
ahhh, I missed the point that you don't own a domain nameFarny
I am working on a WebExtension. It will work with Firefox 57+. It just so happens for particular APIs it is required that the add-on ID be filled out in the same way as legacy extensions, and the documentation for those is on the legacy page.Neysa
yeah, sorry, the page you linked to was for old old school addons - I assumed :pFarny
O
6

The actual requirement is that the ID matches the following RegExp:

var gIDTest = /^(\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}|[a-z0-9-\._]*\@[a-z0-9-\._]+)$/i

The use of a GUID or something approximating an email address is a requirement which is clearly stated in the MDN documentation on Install Manifests (used in legacy add-ons). That it is one or the other is enforced by a check which was placed in the Firefox code as of Firefox 1.5. The above RegExp can be described as:

  1. Must be a GUID using hexadecimal digits in the format {8digits-4digits-4digits-4digits-12digits} or
  2. A string containing a single @ with at least 1 character after the @.
  3. All characters in the @ format must match /[a-z0-9-\._]/i (other than the single @).
  4. The @ format can have zero or more characters prior to the @
  5. The @ format does not need to be a valid email address. It doesn't have to have a valid domain. It doesn't even need to be something which could be a valid email address. It just has to match the RegExp.

It's recommended that if you are selecting an ID, that you use the @ format, not a GUID.

For the @ format, it's generally used as [some ID/name for extension]@[something representing the developer]. While the part before and after the @ tend to have a format that looks like it could be username@domain, I've seen add-on IDs where the "username" is blank and/or the "domain" is a single word. For example, @a would be a valid ID.

The ID must be unique

In addition to the format requirements, there is the requirement that:

  • The ID must be unique across all add-ons that have been submitted to Mozilla (by anyone, ever).

As to it being unique among all add-ons submitted to Mozilla: You'll find out if it's unique when you first attempt to submit it to Mozilla for signing. If it does already exist, you will have to change it in order to successfully submit your add-on.

Orang answered 27/7, 2017 at 8:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.