files/en-us/mozilla/add-ons/webextensions/native_manifests/index.md
Native manifests are JSON files provisioned on the user's computer by means other than the extension installation process. For example, a native manifest might be provisioned by a device administrator or native application installer.
There are three types of native manifest:
<table class="standard-table"> <tbody> <tr> <td> <a href="#native_messaging_manifests">Native messaging manifests</a> </td> <td> Enables a feature called <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging" >native messaging</a >, in which an extension can communicate with a native app installed on the device. </td> </tr> <tr> <td> <a href="#managed_storage_manifests">Managed storage manifests</a> </td> <td> Defines read-only data that an extension can access using the {{WebExtAPIRef("storage.managed")}} API. </td> </tr> <tr> <td><a href="#pkcs_11_manifests">PKCS #11 manifests</a></td> <td> Enables an extension to use the {{WebExtAPIRef("pkcs11")}} API to enumerate PKCS #11 security modules and install them in Firefox. </td> </tr> </tbody> </table>For all native manifests, you need to store the file so the browser can find it. The section on manifest location describes how to do this. On Linux and macOS, the files are in a fixed location, on Windows the file location is written to the Windows Registry.
The native messaging manifest is a file with a name that matches the string passed by the extension into {{WebExtAPIRef("runtime.connectNative()")}} or {{WebExtAPIRef("runtime.sendNativeMessage()")}} with the .json extension. It contains a JSON object with these properties:
For example, here's the content of the ping_pong.json manifest file for the ping_pong native application from the native messaging example:
{
"name": "ping_pong",
"description": "Example host for native messaging",
"path": "/path/to/native-messaging/app/ping_pong.py",
"type": "stdio",
"allowed_extensions": ["[email protected]"]
}
This allows the extension with the ID [email protected] to connect by passing the name ping_pong into the relevant {{WebExtAPIRef("runtime")}} API function. The native application is at /path/to/native-messaging/app/ping_pong.py.
The managed storage manifest is a file with a name that matches the ID specified in the extension's browser_specific_settings key with the .json extension. It contains a JSON object with these properties:
For example, in the favourite-colour example manage storage data is set in the file named [email protected], which contains:
{
"name": "[email protected]",
"description": "ignored",
"type": "storage",
"data": {
"color": "management thinks it should be blue!"
}
}
The [email protected] extension then accesses the data using code like this:
let storageItem = browser.storage.managed.get("color");
storageItem.then((res) => {
console.log(`Managed color is: ${res.color}`);
});
The PKCS #11 manifest is a file with a name that matches the name of the PKCS #11 module (as used in the <code>pkcs11</code> API) with the .json extension. It contains a JSON object with these properties:
For example:
{
"name": "my_module",
"description": "My test module",
"type": "pkcs11",
"path": "/path/to/libpkcs11testmodule.dylib",
"allowed_extensions": ["[email protected]"]
}
Given this JSON manifest, saved as my_module.json, the [email protected] extension could install the security module at /path/to/libpkcs11testmodule.dylib using code like this:
browser.pkcs11.installModule("my_module");
On Linux and macOS, you need to store the manifest in a particular place. On Windows, you need to create a registry key that points to the manifest's location.
The detailed rules are the same for all the manifest types, except that the penultimate component of the path identifies the type of manifest. The examples below show the form for each of the three different types. In all the examples, <name> is the value of the name property in the native manifest.
For global visibility, create a registry key with the following name:
HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\NativeMessagingHosts\<name>
HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\ManagedStorage\<name>
HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\PKCS11Modules\<name>
The key should have a single default value, which is the path to the manifest.
[!WARNING] As of Firefox 64, the 32-bit registry view Wow6432Node will be checked first for these keys, followed by the "native" registry view. Use whichever is appropriate for your application.
For Firefox 63 and older: This key should not be created under Wow6432Node, even if the app is 32-bit. Previous versions of the browser will always look for the key under the "native" view of the registry, not the 32-bit emulation. To ensure that the key is created in the "native" view, you can pass the
KEY_WOW64_64KEYorKEY_WOW64_32KEYflags intoRegCreateKeyEx. See Accessing an Alternate Registry View.
For per-user visibility, create a registry key with the following name:
HKEY_CURRENT_USER\SOFTWARE\Mozilla\NativeMessagingHosts\<name>
HKEY_CURRENT_USER\SOFTWARE\Mozilla\ManagedStorage\<name>
HKEY_CURRENT_USER\SOFTWARE\Mozilla\PKCS11Modules\<name>
The key should have a single default value, which is the path to the manifest.
For global visibility, store the manifest in:
/Library/Application Support/Mozilla/NativeMessagingHosts/<name>.json
/Library/Application Support/Mozilla/ManagedStorage/<name>.json
/Library/Application Support/Mozilla/PKCS11Modules/<name>.json
For per-user visibility, store the manifest in:
~/Library/Application Support/Mozilla/NativeMessagingHosts/<name>.json
~/Library/Application Support/Mozilla/ManagedStorage/<name>.json
~/Library/Application Support/Mozilla/PKCS11Modules/<name>.json
For global visibility, store the manifest in either:
/usr/lib/mozilla/native-messaging-hosts/<name>.json
/usr/lib/mozilla/managed-storage/<name>.json
/usr/lib/mozilla/pkcs11-modules/<name>.json
or:
/usr/lib64/mozilla/native-messaging-hosts/<name>.json
/usr/lib64/mozilla/managed-storage/<name>.json
/usr/lib64/mozilla/pkcs11-modules/<name>.json
For per-user visibility, store the manifest in:
~/.mozilla/native-messaging-hosts/<name>.json
~/.mozilla/managed-storage/<name>.json
~/.mozilla/pkcs11-modules/<name>.json