Commit Graph

129 Commits

Author SHA1 Message Date
Maximilian Krambach
fff365ffc5 js: expect additional 'info' to arrive on decrypt, too
--

* src/permittedOperations.js: if decrypt includes a verification,
  this info needs to pass, too.
2018-08-17 17:55:11 +02:00
Maximilian Krambach
5b0f8230b2 js: decrypt callback is_mime fix
--

* src/gpgmejs: is_mime should report its' counterpart. Also,
  file_name is not optional in specification. We'll send null if
  there is no file_name
2018-08-17 17:44:06 +02:00
Maximilian Krambach
8e87790db3 js: don't expire new keys if no date is set
--

* src/Keyring.js A new Key without expiration is documented as
  'never expire' here, and should behave accordingly. This requires
  sending '0' here.
2018-08-17 17:20:35 +02:00
Maximilian Krambach
3fb094a9b8 js: small documentation fix
--
2018-08-17 17:14:51 +02:00
Maximilian Krambach
ad39d54d19 js: removed Key.armor property in synchronous use
--

* src/Key.js The synchronous mode for a Key does not offer an armor/
  armored property anymore. This frees up a lot of performance issues,
  also the armored expoort is expected to change quite often, so a
  cached version is not advisable.

* hasSecret/getHasSecret is now refactored, to reflect their uses.
  With get('hasSecret') there is a method that fetches the result.

* src/Key.js also some refactoring
2018-08-17 16:57:41 +02:00
Maximilian Krambach
754e799d35 js: disallow bulk set data on key from outside
--

* src/Key.js Key class is not exported anymore, as it should not be
  used directly anywhere. setKeyData is no more a method of the Key,
  (optional) data are now validated and set on Key creation and on
  updates, both from within this module, thus no longer exposing
  setKeyData to the outside.
* createKey now gained an optional parameter which allows to set Key
  data at this point.
2018-08-17 14:40:27 +02:00
Maximilian Krambach
90cb4a6842 js: importKey feedback refactor
--
* src/Keyring.js: An empty result should no longer cause an error,
  the import feedback summary has been refactored slightly
* Browsertests to reflect import feedback change
2018-08-16 17:58:11 +02:00
Maximilian Krambach
d65a392670 js: fix import feedback
--
* src/Keyring.js For Key imports without prepare_sync the import
  feedback was lacking the summary
2018-08-16 17:07:29 +02:00
Maximilian Krambach
ea43158d40 js: avoid async getters
--

* src/Key.js get armored was returning a promise on async keys.
  As getters should not do that, it returns an error in this case.
2018-08-16 14:40:53 +02:00
Maximilian Krambach
43cff51364 js: wrong object assumed in recent commit
--

* src/Keyring.js I wrongly assumed an object to be a GPGME_Key,
  it was the raw answer from nativeMessaging instead. Now it returns
  a GPGME_Key again.
2018-08-16 12:13:10 +02:00
Maximilian Krambach
715cdc0d7d js: get default key fixes
--

* src/Keyring.js: The answer was not parsed correctly, so a config was
  being ignored.

* If no config is set, we return the first non-invalid key with a
  secret, instead of the first key (which may be e.g. an expired one)
2018-08-16 12:03:30 +02:00
Maximilian Krambach
aeb065acc9 js: simplify getDefaultKey
--

* src/Keyring.js: In case no default Key is set in configuration,
  only Keys reported as having a secret part should be considered
  for default Keys, avoiding some extra requests.
2018-08-16 11:29:10 +02:00
Maximilian Krambach
622db0d1de js: consistently return uppercase fingerprint
--

* src/Key.js: the fingerprint returned by a Key is now always upper
  case hex, even if the constructor had lower case input. This is to be
  more consistent with gpgme and to be more readable and reliable in
  comparisions.
2018-08-16 11:25:50 +02:00
Maximilian Krambach
68a012deb3 js: make init export immutable
--

* src/index.js: The export now uses a freezed Object, which does not
  allow for simply overwriting the init method by e.g. a third-party
  library.
* BrowsertestExtension: Added some tests trying if decryption of bad
  data properly fails
2018-08-01 12:51:12 +02:00
Maximilian Krambach
6313a2de9e js: fix confusion about loop in last commit
--

* The aim is to iterate through the results of the first request
 (all keys), and then add the propert 'hasSecret' to those that
  are in the second request (secret Keysring)  as well. I messed
  this up in a recent change, and it escaped testing.
2018-07-31 17:35:52 +02:00
Maximilian Krambach
9d247b7fd5 js: Fix Key.hasSecret answer
--

* The comparision result between Keyring and Keyring with secrets was
  set to the wrong Object which was not returned at all.
2018-07-31 16:54:43 +02:00
Maximilian Krambach
e16a87e839 js: Making objects inmutable
--

* An Object.freeze should stop any malicious third party from changing
  objects' methods once the objects are instantiated (see unittest for
  an approach that would have worked before)
  - An initialized gpgmejs- object doesn't have a '_Keyring' property
    anymore (it still has its 'Keyring')
  - The internal expect='base64' needed to be turned into a method.
2018-07-30 12:31:27 +02:00
Maximilian Krambach
522121ea7e js: fix indentaion
--

* doing the indentation changes that became neccesary in the last
  commit.
2018-07-27 20:56:11 +02:00
Maximilian Krambach
94ee0988d4 js: change the write access for js class methods
--
* src/ [Connection, Error, Key, Keyring, MEssage, Signature, gpgmejs]:
    Functions and values that are not meant to be overwritten are now
    moved into their constructors, thus eliminating the possibility of
    overwrites after initialization.

* Key: The mode of use (synchronous cached, or async promises) ivs now
  determined at initialization of that Key. The property Key.isAsync
  reflects this state.

* unittests: fixed old Key syntax for testing.

* Message.js isComplete is now a method and not a getter anymore.

* Added some startup tests.
2018-07-27 20:36:21 +02:00
Maximilian Krambach
b18b96fb36 js: clean up test extension
--

Tests will now run with one instance of gpgmejs each block,
which reduces overhead. Readability is (hopefully) improved),
some negative tests are added.

There is still a performance problem in base64 encoding/decoding,
which causes some tests to fail due to time out.
2018-07-27 11:20:33 +02:00
Maximilian Krambach
4b343c4e33 js: include armored Key in import callback
--

* The import answer now also directly contains the armored Key as Key
  property, without need to refresh the Key object created in the
  answer. This allows for direct comparision of input and output.
* BrowserTestExtension: added test for that import callback
2018-07-24 14:56:33 +02:00
Maximilian Krambach
040b1ed40a js: Fix wrong encoding in received error messages
--

* The libgpg error strings arrive in the browser in a different
  encoding than used by browsers. Escaping and then decoding it
  should cover most languages in the supported browsers.
2018-07-24 14:50:54 +02:00
Maximilian Krambach
a965e3e0b8 js: repair BrowserTextExtension test
--

* the signed message to verify was signed by a wrong test key
2018-07-20 10:59:57 +02:00
Maximilian Krambach
50da3ff2fd js: typo in comment
--

* Documentation typo that caused jsdoc to exit with an error
2018-07-18 13:43:47 +02:00
Maximilian Krambach
ce0379d999 js: fix getkeys with locate option
--

* src/Keyring.js:
  As locate will not work with the "secret" option, the first message
  cannot be reused, thus a new one must be created here
2018-07-17 11:07:49 +02:00
Maximilian Krambach
5213a599fe js: allow optional Key retrieve pattern to be null
--

* src/Keyring.js: If the optional "pattern" parameter is not to be
  used, but another, following parameter is, null is more of a
  convention in javascript, thus both null and undefined are
  interpreted as "this parameter is not meant to be set".
2018-07-12 11:48:17 +02:00
Maximilian Krambach
30bb549046 js: add with-sec-fprs to getKeysArmored
--

* Reflects the changes made to gpgme-json in commit
  6cc842c9aa.

  - getKeysArmored now returns an object with property 'armored' being
    the exported armored block, and an (optional) array of fingerprint
    strings for those keys that can be used in sign/encrypt operations
    as property 'secret_fprs'. With this, extensions such as mailvelope
    will be able to bulk fetch all necessary key information in one
    request.
2018-07-12 11:36:55 +02:00
Maximilian Krambach
4015f5b498 js: documentation
--

* Fixed errors:
- src/Message.js post(): Set chunksize to defined default value instead
  of hardcoded
- src/Keys.js: added getHasSecret() to refreshKey operation.

* Reviewed and updated the documentation

* non-documentation changes which do not affect functionality:
- src/Errors: disabled a console.warn that is only useful for debugging
- helpers.js: renamed "string" to "value" in isFingerprint and isLongId
  to avoid confusion
- src/Keyring: prepare_sync, search are both explicitly set to false by
  default
2018-07-10 14:32:26 +02:00
Maximilian Krambach
8964627f6a js: fix verify result reporting
--

* src/Signature.js: searching for overall validity in the "summary"
  property
* BrowsertestExtension: Added two verify tests
2018-07-09 11:57:01 +02:00
Maximilian Krambach
67b6fa5a29 js: reduce request spam at getKeys()
--

* Don't make a secret-Key request for each Key retrieved, use one
  request for all of them instead, and assemble the info later. This
  should reduce the traffic with large Keyrings. The bulk retrieval
  for the public armored Keys for each of these Keys is still up to
  discussion

* unittests: disabled assertion for the armored key (as it currently
  doesn't work)

* encryptTest: clarified the mechanism/reason of rejection for
  Messages >64 MB. This is still a TODO, as this error comes from a
  different place (the browser itself) and behaves different from the
  other errors.
2018-07-09 11:24:46 +02:00
Maximilian Krambach
10f2106404 js: properly reject pgp message without signature
--

* A verify at gpgme-json does not fail if there is a valid pgp message
  that does not include a signature. Instead, the answer will be devoid
  of signatures. In javascript, the SIG_NO_SIG error should be reported
  here, but wasn't.
2018-07-04 15:46:45 +02:00
Maximilian Krambach
1919fa41b6 js: Add jsdoc, update webpack-cli dependency
--
* package.json:
  - the old webpack-cli version depended on two packages
    with vulnerabilities, set to minimum version 3.0.8 to fix this
    (nodesecurity.io/advisories/157, nodesecurity.io/advisories/612)
  - added License identifier

* README: Updated documentation

* jsdoc.conf: Added a configuration file for jsdoc

* some minor documentation changes, indentations
2018-07-04 13:38:54 +02:00
Maximilian Krambach
1105fc87a3 js: add Key lookup
--

* src/Keyring.js: getKeys() now has the option "search", which will
  trigger a remote lookup (as configured in gpg) for the string given
  as pattern.
* src/permittedOperations: make use of the new 'locate' option in
  keylist
* DemoExtension: Add a button for lookup, to demonstrate the
  functionality
2018-07-04 12:11:35 +02:00
Maximilian Krambach
a52ec87d40 js: fixing Key import/export test
--

* BrowserTestExtension:
 - The KeyImport/Export test had some errors, which have now been fixed
 - The secret key used for the test examples is now placed more
   prominently, and a clarification added that decrypt tests will not
   work if this key is not imported.

* permittedOperations.js: typo

  Thanks to rrenkert@intevation.de for the fixes
2018-07-03 12:41:49 +02:00
Maximilian Krambach
88e7f8ec2e js: Demoextension update
--

* src/Signature: typo
* src/gpgmejs.js: fixed wrong scope in verification
* right now verify does not succeed in the DemoExtension.
  This is probably a problem in conversion or line ending.
2018-06-20 13:46:41 +02:00
Andre Heinecke
d27703ea4f
Prepare build system for gpgme-js and dist it
* configure.ac: Add js as language.
* lang/Makefile.am: Add js as dist language.
* lang/js/BrowserTestExtension/Makefile.am,
lang/js/DemoExtension/Makefile.am,
lang/js/Makefile.am,
lang/js/src/Makefile.am: Populate EXTRA_DIST variables.

--
There is no actual build done yet as there seems to be
no way to build it with debian stable tools. This needs
clarification.
2018-06-19 16:40:40 +02:00
Maximilian Krambach
780f7880c6 js: getDefaultKey and GenerateKey improvements
--

* src/Keyring.js: added more options for key generation.

* src/Key.js: GetDefaultKey now relies on the info associated with the
  key, as the approach of relying on a secret subkey did not work as
  intended
* DemoExtension: Added a button for retrieval of the subkey, to test
  this functionality.
2018-06-19 09:26:01 +02:00
Maximilian Krambach
3cd428ba44 js: import result feedback
--

* src/Keyring.js: Changed and documented the import result feedback
  towards the javascript side
2018-06-14 14:50:25 +02:00
Maximilian Krambach
3c783bd09c js: add verify and signature parsing
--

* src/gpgmejs.js:
  - Added verify method
  - Added verification results in decrypt (if signatures are present
    in the message)
  - Added a base64 option to decrypt

* src/Signature.js: Convenience class for verification results. Used
   for e.g. converting timestamps to javascript time, quick overall
   validity checks

* src/Keyring.js: removed debug code

* src/Errors.js add two new Signature errors
2018-06-14 12:15:51 +02:00
Maximilian Krambach
aed402c5d5 js: getDefaultKey and verify fix
--

* DemoExtension/maindemo.js - added a Demo for retrieving the default
  signing key

* src/Errors.js - add a new Error if no default key can be determined

* src/Key.js added documentation and a TODO marker for hasSecret.

* src/Keyring.js implemented getDefaultKey

* src/permittedOperations.js: Added missing entry for verify,
    added config_opt
2018-06-13 15:22:03 +02:00
Maximilian Krambach
d0fc4ded58 js: less confusing icons for test/Demo extension
--
* The current test icon was just a generic pin. Changed that by the
  gnupg lock symbol with 'Demo'/'Tests' written on it. Original taken
  from gnupg artwork/icons/lock-wing.svg.
2018-06-13 11:49:37 +02:00
Maximilian Krambach
e154554e9a js: removed config
--

* There is no use for a configuration at the moment, and it seems
  improbable that this use will arise.
2018-06-11 15:10:43 +02:00
Maximilian Krambach
e97e6c06e9 js: Add key creation to Keyring
--

* src/Keyring.js: Added method generateKey for new Keys
  Still TODO: Key length and some further testing. Automated testing
  does not work in this case, and gpgmejs will not be able to delete
  test keys again.
* src/permittedOperations.js Added new method's definitions according
  to gpgme-json
2018-06-11 12:08:50 +02:00
Maximilian Krambach
c072675f3f js: change chunksize handling and decoding
--

* the nativeApp now sends all data in one base64-encoded string, which
  needs reassembly, but in a much easier way now.

* there are some new performance problems now, especially with
  decrypting data
2018-06-08 17:54:58 +02:00
Maximilian Krambach
7a072270ac js: change Keyinfo timestamps into javascript date
--
* src/Key.js
2018-06-06 15:29:21 +02:00
Maximilian Krambach
bfd3799d39 js: code cleanup (eslint)
--
* trying to stick to eslint from now on for readability

* As some attribution was lost in previous git confusions, I added my
  name into some of the licence headers
2018-06-06 13:05:53 +02:00
Maximilian Krambach
0356a667c5 js: implement import/delete Key, some fixes
--

* Keyring.js
   - implemented importKey: importing one or more armored public key
     blocks.
   - implemented deleteKey: deleting a public Key from gpg.

* Key.js renamed property Key.armor to Key.armored

* Helpers.js: toKeyIDArray does not complain anymore if there are no
  keys. Not having Keys in e.g. signing keys in encrypt is legitimate
  and common, the complaints were getting spammy

* Errors.js: gpgme_errors now always pass an optional additional
  message, for easier debugging in minified code

* Connection.js: Fix in gpgme-json responses containing objects

* eslintrc.json: Start using eslint. A cleanup to conform to it is not
  done yet

* Added further tests for the new functionality
2018-06-06 11:57:41 +02:00
Maximilian Krambach
332b4adbcc js: more Keyring/Key handling
--

* src/Keys.js
  - made setKeyData more consistent with other methods
  - added convenience methods (Key.armored, Key.hasSecret)
  - Added a Key delete function

* src/Keyring.js:
  - added a getkeysArmored which allows for bulk export of public Keys

gpgmejs:
  - removed deleteKey. It is now a method of the Key itself
  - Encrypt: Added some common options as parameter, and the
    possibility to set all allowed flags via an additional Object
2018-05-30 17:05:54 +02:00
Maximilian Krambach
53ce2b94bc js: Keyring listing keys
--

* implementing Keyring methods:

  - Keyring.getKeys: has an additional option that retrieves the armor
    and secret state once at the beginning. This is power hungry, but
    allows for Keys to be used directly (without querying gpgme-json
    each call)
  * permittedOperations.js: reflect recent changes in the native
    counterpart, adding more options
  * Key: adding two methods for retrieving the armored Key block and
    for finding out if the Key includes a secret subkey.
2018-05-28 17:26:56 +02:00
Maximilian Krambach
d4adbf453d js: Treat a connection as a gpgme Context
--

* After an operation a connection should be disconnected again.
  The "end of operation" is now assumed to be either an error as
  answer, or a message not including a "more"

* GPGME, GPGME_Key, GPGME_Keyring don't require a connection
  anymore
* Message.js: The Message.post() method will open a connection as
  required
2018-05-28 16:52:50 +02:00
Maximilian Krambach
7a73d88aba js: implement Key handling (1)
--

* Keys can now be queried for information. Onne version queries gnug
  directly (asynchronous Promise in javascript terms), the cached
  version refreshes on demand.

* Small fixes:
  src/Connection.js joins answers that stay json properly now
2018-05-25 19:02:18 +02:00
Maximilian Krambach
eff27d6387 js: use version operation for connection checks
--

* src/Connection.js: isConnected was renamed to checkConnection, that
  returns a promise with either version information or Boolean
* Connection checks have been adapted to reflect that checkConnection
  returns a Promise
* BrowsertestExtension: tests/signTest.js was missing from my last
  commit
2018-05-25 11:53:24 +02:00
Maximilian Krambach
a4ba80c553 js: adding sign method
--

  * src/gpgmejs.js: method, update in src/permittedOperations
  * basic testing in BrowsertestExtension
2018-05-24 15:16:18 +02:00
Maximilian Krambach
f7ed80ff6a js: remove openpgp mode
--

* After discussion, that mode is not required, and can result in
  being quite misleading and a maintenance hassle later on.
2018-05-23 12:56:23 +02:00
Maximilian Krambach
ecad772635 js: transfer encoding changes
--

* Uint8Arrays are not supported for now there are unsolved issues in
  conversion, and they are lower priority

* encrypt gains a new option to indicate that input values are base64
  encoded
* as decrypted values are always base64 encoded, the option base64 will
  not try to decode the result into utf, but leave it as it is
2018-05-22 14:24:16 +02:00
Maximilian Krambach
6b4caee039 js: Testing lare messages
--

* Some assumption on messages were wrong. Now the tests use more
  reasonable sizes.
* bigString now uses the full utf8-extent, with the exception of
  U+0000. This code gets dropped during the encryption-decryption
  process.
2018-05-14 19:02:49 +02:00
Maximilian Krambach
d1ca90ef75 js: remove non-browser tests
--

* The majority of tests needs to be run in a nativeMessaging context.
  Offering the few tests that don't need this context at two places
  introduces issues with maintainability. All tests now removed can be
  found in ./unittests.js
2018-05-14 16:36:05 +02:00
Maximilian Krambach
987b317468 js: Tests and improvements for openpgp mode
--

* Added openpgp - Mode tests to the browsertest Extension. These tests
  require openpgp, which should not be a hard dependency for the main
  project. Packing openpgpjs into the extension is still TODO

* Fixes:
  - openpgp mode API now correctly handles parameters as an object,
    similar to openpgpjs
  - proper check and parsing of openpgpjs Message Objects
2018-05-14 16:23:24 +02:00
Maximilian Krambach
c92326cc25 js: more testing of nativeMessaging connection
--

* There were some inconsistencies between utf-8, transfer and browsers'
  utf16, which broke characters that were split between individual
  messages. src/Connection now contains a workaround that reassembles
  javascripts' format from passed base64 strings. This needs someone
  more experienced looking.
* Added several new tests which were failing during initial debugging
  of this issue
* reorganized BrowsertestExtension to avoid cluttering.
2018-05-09 19:40:57 +02:00
Maximilian Krambach
cca40627b0 js: more testing
--

* Tests: Under certain circumstances, some data change during
  encrypt-decrypt. Committing the current state so the problem can be
  discussed.

* Fixes:
  - disconnecting the test ports after tests are complete
  - fixed passing of the error message from gpgme-json
2018-05-08 18:33:41 +02:00
Maximilian Krambach
8f3d83e5f0 js: fixing errors found by testing: encrypt/decrypt
--

* Key.js: Error code for wrong parameter in createKey should be
  "PARAM_WRONG"
* Helpers.js: The property openpgpjs-like Objects were checked for in
  toKeyIdArray was not defined.
* src/permittedOperations.js: updated more expectations and assumptions
  for the native API

* new Problems:
  - There seems to be a message size limit of about 21 MB for
    nativeMessaging, much lower than the documented 4GB.
  - Some bytes are lost with random data in an encrypt-decrypt
    roundtrip. The culprit is unclear.
2018-05-07 18:27:25 +02:00
Maximilian Krambach
cf075846fb js: fixing errors found by testing
--

* Key.js: Error code for wrong parameter in createKey should be
  "PARAM_WRONG"

* Helpers.js: The property openpgpjs-like Objects were checked for in
  toKeyIdArray was not defined.

* src/permittedOperations.js: updated more expectations and assumptions
  for the native API
2018-05-04 12:56:59 +02:00
Maximilian Krambach
c755287ba8 js: Added browser testing for unit tests
--

* Added unittests to be run inside a Browser. To be able to access
  the non-exposed functions and classes, a testing bundle will be
  created, containing the tests (unittests.js) and the items to be
  tested.
* src/Helpelpers, src/Key, src/Keyring: fixed some errors found
  during testing.
2018-05-03 18:03:22 +02:00
Maximilian Krambach
6f67814eb4 js: changed Key class stub
--

* src/Key.js:
  A Key object cannot offer more than basic functionality outside a
  connection, so it now requires a connection to be present.
2018-05-03 14:12:10 +02:00
Maximilian Krambach
fda7b13f1b js: more testing
--

* Tests: initialization of the two modes, encryption

* gpgme.js: reintroduced message check before calling
  Connection.post()

* gpgmejs_openpgp.js: Fixed openpgp mode not passing keys

* index.js: fixed some confusion in parseconfig()

* Inserted some TODO stubs for missing error handling
2018-04-27 20:03:09 +02:00
Maximilian Krambach
eb7129f319 js: fixed empty operation setter in Message
--

* src/Message.js Messages failed because they were not assigned
  operations
2018-04-27 10:21:13 +02:00
Maximilian Krambach
f45b926816 js: fixed wrong paths in DemoExtension
--

* Some forgotten internal links after the move to a subdir and cleaning
2018-04-26 17:59:40 +02:00
Maximilian Krambach
1f7b19512c js: created TestExtension and smaller fixes
--

* Extensions:

  - Moved testapplication to Demoextension
  - Created BrowserTestExtension.
    Includes mocha and chai. For running tests that cannot be run
    outside a WebExtension

  Both Extensions can be found zipped in build/extensions after
  running build_extensions.sh

* Code changes:
  - src/Config: Place for the configuration
  - small fixes raised during testing in Keyring.js, Message.js,
  - src/gpgmejs_openpgpjs.js don't offer direct GpgME object to the
    outside, as it only causes confusion
  - index.js init() now checks the config for validity

* Tests:
  - Reordered tests in test/.
  - Input values are now in a separate file which may be of use for
    bulk testing

* moved the build directory from dist to build
2018-04-26 17:13:34 +02:00
Maximilian Krambach
3685913bf5 js: First testing and improvements
--

* Introduced Mocha/chai as testsuite. After development build
  'npm test' should run the unit tests. Functionality exclusive to
  Browsers/WebExtensions cannot be run this way, so some other testing
  is still needed.

  - package.json: Added required development packages
  - .babelrc indirect configuration for mocha. ES6 transpiling
    needs some babel configuration, but mocha has no setting for it.
  - test/mocha.opts Vonfiguration for mocha runs

* Fixed errors:
  - Helpers.js toKeyIdArray; isLongId is now exported
  - Key.js Key constructor failed
  - Message.js will not throw an Error during construction, a new
    message is now created with createMessage, which can return an
    Error or a GPGME_Message object

* Tests:
  - test/Helpers: exports from Helpers.js, GPGME_Error handling
  - test/Message: first init test with bad parameters
2018-04-25 19:45:39 +02:00
Maximilian Krambach
1fb310cabe js: Configuration and Error handling
--

* gpgmejs_openpgpjs
  - unsuported values with no negative consequences can now reject,
    warn or be ignored, according to config.unconsidered_params
  - cleanup of unsupported/supported parameters and TODOS

* A src/index.js init() now accepts a configuration object

* Errors will now be derived from Error, offering more info and a
  stacktrace.

* Fixed Connection.post() timeout triggering on wrong cases

* Added comments in permittedOperations.js, which gpgme interactions
  are still unimplemented and should be added next
2018-04-25 15:59:36 +02:00
Maximilian Krambach
5befa1c975 js: reactivate timeout on connection
--
* A timeout of 5 seconds is activated for functions that do not require
  a pinentry. This definition is written to src/permittedOperations.js
* testapplication.js now alerts the proper error codes and messages.
* src/Errors.js fixed two typos in error handling
2018-04-25 11:32:21 +02:00
Maximilian Krambach
c72adc0096 js: change in Error behaviour
--

* Error objects will now return the error code if defined as error type
  in src/Errors.js, or do a console.log if it is a warning. Errors from
  the native gpgme-json will be marked as GNUPG_ERROR.
2018-04-25 10:54:24 +02:00
Maximilian Krambach
30c47d80a2 js: allow openpgp-like Message objects as Data
--

* src/gpgmejs.js: If a message offers a getText, consider it as the
  message's content
2018-04-25 09:23:38 +02:00
Maximilian Krambach
e2aa8066a9 js: Key object adjustments after discussion
--

* src/aKey.js changed fingerprint to setter (to avoid overwrites)
* src/gpgmejs_openpgpjs.js
  - Added a class GPGME_Key_openpgpmode, which allows for renaming and
    deviation from GPGME.
  - renamed classes *_openPGPCompatibility to *_openpgpmode. They are
    not fully compatible, but only offer a subset of properties. Also,
    the name seems less clunky
2018-04-24 19:29:32 +02:00
Maximilian Krambach
461dd0c8b4 js: change in initialization ancd connection handling
--

* The Connection will now be started before an object is created, to
  better account for failures.
* index.js: now exposes an init(), which returns a Promise of
  configurable <GpgME | gpgmeGpgME_openPGPCompatibility> with an
  established connection.
* TODO: There is currently no way to recover from a "connection lost"
* Connection.js offers Connection.isConnected, which toggles on port
  closing.
2018-04-24 18:44:30 +02:00
Maximilian Krambach
727340b295 js: don't allow message operation changes
--

Once an operation is changed, their set of allowed/required parameters
will change. So we shouldn't set/change the operation later.
2018-04-23 19:15:40 +02:00
Maximilian Krambach
d62f66b1fb js: Key handling stubs, Error handling, refactoring
--

* Error handling: introduced GPGMEJS_Error class that handles errors
  at a more centralized and consistent position
* src/Connection.js:
  The nativeMessaging port now opens per session instead of per
  message. Some methods were added that reflect this change
  - added methods disconnect() and reconnect()
  - added connection status query
* src/gpgmejs.js
  - stub for key deletion
  - error handling
  - high level API for changing connection status
* src/gpgmejs_openpgpjs.js
  - added stubs for Key/Keyring handling according to current
    state of discussion. It is still subject to change
* src/Helpers.js
  - toKeyIdArray creates an array of KeyIds, now accepting
    fingerprints, GPGMEJS_Key objects and openpgp Key objects.
* Key objects (src/Key.js) Querying information about a key
  directly from gnupg. Currently a stub, only the Key.fingerprint is
  functional.
* Keyring queries (src/Keyring.js): Listing and searching keys.
  Currently a stub.
2018-04-23 17:18:46 +02:00
Maximilian Krambach
6ab25e40d9 js: encrypt improvement and decrypt method
* Compatibility class gpgme_openpgpjs offers an API that should accept
  openpgpjs syntax, throwing errors if a parameter is unexpected/not
  implemented
* tried to be more generic in methods
* waiting for multiple answers if 'more' is in the answer
* more consistency checking on sending and receiving
* updated the example extension
--
2018-04-20 15:24:13 +02:00
raimund.renkert@intevation.de
eef3a509fa
js: Initial commit for JavaScript Native Messaging API
--

Note this code misses all the legal boilerplate; please add this as
soon as possible and provide a DCO so we can merge it into master.

I also removed the dist/ directory because that was not source code.
2018-04-10 18:47:59 +02:00