2018-07-10 12:32:26 +00:00
|
|
|
gpgme.js, as contained in this directory, is a javascript library for direct use
|
2018-04-18 14:38:06 +00:00
|
|
|
of gnupg in browsers, with the help of nativeMessaging.
|
2018-04-10 09:33:14 +00:00
|
|
|
|
2018-07-10 12:32:26 +00:00
|
|
|
Prerequisites:
|
|
|
|
--------------
|
|
|
|
gpgme.js will make use of the application gpgme-json, which is distributed with
|
|
|
|
gpgme. Gpgme-json needs to be installed; it will further need to accept the
|
|
|
|
browser extension in the manifest file.
|
|
|
|
|
|
|
|
Building gpgme.js
|
|
|
|
-----------------
|
|
|
|
gpgme.js uses webpack, and thus depends on nodejs for building. All
|
|
|
|
dependencies will be installed (in a local subdirectory) with the command
|
|
|
|
`npm install`.
|
2018-04-10 09:33:14 +00:00
|
|
|
|
2018-04-18 14:38:06 +00:00
|
|
|
To create a current version of the package, the command is
|
|
|
|
`npx webpack --config webpack.conf.js`.
|
2018-04-10 09:33:14 +00:00
|
|
|
If you want a more debuggable (i.e. not minified) build, just change the mode
|
|
|
|
in webpack.conf.js.
|
|
|
|
|
2018-07-04 11:38:54 +00:00
|
|
|
Demo and Test WebExtension:
|
|
|
|
---------------------------
|
|
|
|
|
2018-07-10 12:32:26 +00:00
|
|
|
The Demo Extension shows simple examples of the usage of gpgme.js.
|
2018-07-04 11:38:54 +00:00
|
|
|
|
|
|
|
The BrowsertestExtension runs more intensive tests (using the mocha and chai
|
|
|
|
frameworks). Tests from BrowserTestExtension/tests will be run against the
|
|
|
|
gpgmejs.bundle.js itself. They aim to test the outward facing functionality
|
|
|
|
and API.
|
|
|
|
|
|
|
|
Unittests as defined in ./unittests.js will be bundled in
|
2018-07-10 12:32:26 +00:00
|
|
|
gpgmejs_unittests.bundle.js, and test the separate components of gpgme.js,
|
2018-07-04 11:38:54 +00:00
|
|
|
which mostly are not exported.
|
|
|
|
|
2018-07-10 12:32:26 +00:00
|
|
|
The file `build_extension.sh` may serve as a pointer on how to build and
|
|
|
|
assemble these two Extensions and their dependencies. It can directly
|
2018-07-04 11:38:54 +00:00
|
|
|
be used in most linux systems.
|
|
|
|
|
|
|
|
The resulting folders can just be included in the extensions tab of the browser
|
|
|
|
in questions (extension debug mode needs to be active). For chrome, selecting
|
|
|
|
the folder is sufficient, for firefox, the manifest.json needs to be selected.
|
2018-04-18 14:38:06 +00:00
|
|
|
Please note that it is just for demonstration/debug purposes!
|
2018-04-10 09:33:14 +00:00
|
|
|
|
2018-07-04 11:38:54 +00:00
|
|
|
For the Extensions to successfully communicate with gpgme-json, a manifest file
|
|
|
|
is needed.
|
|
|
|
|
|
|
|
- `~/.config/chromium/NativeMessagingHosts/gpgmejson.json`
|
|
|
|
|
2018-04-10 09:33:14 +00:00
|
|
|
In the browsers' nativeMessaging configuration folder a file 'gpgmejs.json'
|
|
|
|
is needed, with the following content:
|
|
|
|
|
2018-07-04 11:38:54 +00:00
|
|
|
- For Chrome/Chromium:
|
|
|
|
```
|
|
|
|
{
|
|
|
|
"name": "gpgmejson",
|
2018-07-10 12:32:26 +00:00
|
|
|
"description": "This is a test application for gpgme.js",
|
2018-07-04 11:38:54 +00:00
|
|
|
"path": "/usr/bin/gpgme-json",
|
|
|
|
"type": "stdio",
|
|
|
|
"allowed_origins": ["chrome-extension://ExtensionIdentifier/"]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
The usual path for Linux is similar to:
|
|
|
|
`~/.config/chromium/NativeMessagingHosts/gpgmejson.json` for
|
|
|
|
For Windows, the path to the manifest needs to be placed in
|
|
|
|
`HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts\gpgmejson`
|
|
|
|
|
|
|
|
- For firefox:
|
|
|
|
```
|
|
|
|
{
|
|
|
|
"name": "gpgmejson",
|
2018-07-10 12:32:26 +00:00
|
|
|
"description": "This is a test application for gpgme.js",
|
2018-07-04 11:38:54 +00:00
|
|
|
"path": "/usr/bin/gpgme-json",
|
|
|
|
"type": "stdio",
|
|
|
|
"allowed_extensions": ["ExtensionIdentifier@temporary-addon"]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
The ExtensionIdentifier can be seen as Extension ID on the about:addons page
|
|
|
|
if addon-debugging is active. In firefox, the temporary addon is removed once
|
|
|
|
firefox exits, and the identifier will need to be changed more often.
|
|
|
|
|
|
|
|
The manifest for linux is usually placed at:
|
|
|
|
`~/.mozilla/native-messaging-hosts/gpgmejson.json`
|
|
|
|
|
|
|
|
Documentation
|
|
|
|
-------------
|
|
|
|
|
|
|
|
The documentation can be built by jsdoc. It currently uses the command
|
|
|
|
`./node_modules/.bin/jsdoc -c jsdoc.conf`.
|