gpgme/lang/js
Maximilian Krambach 60dc499abd js: update getDefaultKey to more precise logic
--

* src/Keyring.js: Adapted Keyring.getDefaultKey() to my current
  understanding  of a default signing key: either the default key set
  in the gpg config, or 'the first usable private key' - usability
  meaning  'not invalid, expired, revoked, and can be used for
  signing'. It should be the same key used as in command line when
  doing a --sign operation.
  In case the user has a smartcard plugged in, we currently
  won't know of this here, so our choice may differ. But as we do all
  javascript-binding sign operations with the key  fingerprint
  explicitly set, this should not be a real problem. This method is
  seen more as a convenience to tell using librarys which key
  represents the main user.
2018-08-23 11:28:18 +02:00
..
BrowserTestExtension js: add decrypt result options 2018-08-22 19:07:05 +02:00
DemoExtension js: make method parameters objects 2018-08-22 18:37:46 +02:00
src js: update getDefaultKey to more precise logic 2018-08-23 11:28:18 +02:00
.babelrc js: First testing and improvements 2018-04-25 19:45:39 +02:00
.eslintrc.json js: add and apply eslint rules 2018-08-20 15:12:01 +02:00
build_extensions.sh js: Added browser testing for unit tests 2018-05-03 18:03:22 +02:00
jsdoc.conf js: Add jsdoc, update webpack-cli dependency 2018-07-04 13:38:54 +02:00
Makefile.am js: remove outdated checklists 2018-08-21 14:37:50 +02:00
package.json js: Add jsdoc, update webpack-cli dependency 2018-07-04 13:38:54 +02:00
README js: Improve README 2018-08-21 13:58:51 +02:00
unittest_inputvalues.js js: add and apply eslint rules 2018-08-20 15:12:01 +02:00
unittests.js js: throw errors in sync functions 2018-08-22 12:18:55 +02:00
webpack.conf_unittests.js js: Add jsdoc, update webpack-cli dependency 2018-07-04 13:38:54 +02:00
webpack.conf.js js: Add jsdoc, update webpack-cli dependency 2018-07-04 13:38:54 +02:00

gpgme.js - JavaScript for GPGME
-------------------------------
Initially developed for integration with the Mailvelope Web Extension.

Overview
--------

gpgme.js is a javascript library for direct use of GnuPG in browsers.
It interacts with GPGME through nativeMessaging and gpgme-json.

It is meant to be distributed directly by its downstream users in
their extension package. As such it is not integrated in the
autotools build system. See build instructions below.


gpgme-json
----------

gpgme-json (see core src/gpgme-json.c) the json to GPGME bridge is
required as native messaging backend for gpgme.js to work.
It needs to be installed and registered as native messaging
backend with the browser.

See gpgme-mozilla.json and gpgme-chrome.json examples in
the top level doc/examples as example manifests.

Any web extension using gpgme.js will need to be whitelisted in the manifest
file by its id.

Distributors are encouraged to create manifest packages for their
distributions.


Building gpgme.js
-----------------

gpgme.js uses webpack, and thus depends on Node.js for building.
All dependencies will be installed (in a local subdirectory) with the command
`npm install`.

To create a current version of the package, the command is
`npx webpack --config webpack.conf.js`.
If you want a more debuggable (i.e. not minified) build, just change the mode
in webpack.conf.js.


Demo and Test WebExtension:
---------------------------

The Demo Extension shows simple examples of the usage of gpgme.js.

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
gpgmejs_unittests.bundle.js, and test the separate components of gpgme.js,
which mostly are not exported.

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
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.
Please note that it is just for demonstration/debug purposes!

For the Extensions to successfully communicate with gpgme-json, a manifest file
is needed.

- `~/.config/chromium/NativeMessagingHosts/gpgmejson.json`

In the browsers' nativeMessaging configuration folder a file 'gpgmejs.json'
is needed, with the following content:

- For Chrome/Chromium:
  ```
  {
    "name": "gpgmejson",
    "description": "This is a test application for gpgme.js",
    "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",
    "description": "This is a test application for gpgme.js",
    "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`.