Commit Graph

17 Commits

Author SHA1 Message Date
Maximilian Krambach
5d6039f6bf js: decoding of information
--

* src/Helpers.js: This additional escape should 'repair' special
  characters like spaces in filenames. In the strange world of
  encoding there is little hope that this captures all cases, or
  that it will never fail to return some value, let alone meaningful.
  In my test cases it worked.
2018-08-30 15:37:37 +02:00
Maximilian Krambach
28086252f1 js: make non-payload data more encoding-tolerant
--

* src/Helpers.js: As non-payload data might come in different
  encodings, a conversion has been introduced that worked in most
  cases. Data like the userid might come in different encodings,
  which we don't know of. For now, a try..catch returns the data
  as they are if the utf-8 decoding fails. Sometimes this yields the
  correct result, sometimes it may not work, but it won't stop the
  whole operation anymore.
2018-08-27 13:00:50 +02:00
Maximilian Krambach
129fa919b9 js: improve decryption performance
--
* src/Connection.js, src/Helpers.js: performance of decoding incoming
  base64 data was improved to about 4 times the speed by introducing
  two more efficient functions (thanks to rrenkert@intevation.de for
  finding and testing them)

* src/gpgmejs.js: Decrypted data will now return as Uint8Array, if the
  caller does not wish for a decoding. Decoding binary data will return
  invalid data, and a Uint8Array may be desired. This can be indicated
  by using the (new) 'binary' option in decrypt.

* src/Errors.js A new error in case this decoding fails

* src/Message.js, src/Connection.js: expected is change from base64
  to binary, to avoid confusion later on.
2018-08-22 16:32:31 +02:00
Maximilian Krambach
dd32daad0b js: add and apply eslint rules
--

* mainly spacing, see .eslintrc.json for details
2018-08-20 15:12:01 +02:00
Maximilian Krambach
74684f24c6 js: decode arriving gpg message strings
--

* Arriving strings (i.e. user id names, error messages) are not
  always in javascript encoding. This is an attempt to go through
  the whole gpgme answer (with the exception of payload data) and
  to fix the encoding of these
2018-08-17 19:20:35 +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
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
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
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
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
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
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
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