diff options
author | Maximilian Krambach <[email protected]> | 2018-08-27 09:50:09 +0000 |
---|---|---|
committer | Maximilian Krambach <[email protected]> | 2018-08-27 09:50:09 +0000 |
commit | 4f28fbddd3d70eb7e3ce874b1673630142110b72 (patch) | |
tree | 29c9e5e68d025b6403b68941396a5b94783f1d83 /lang/js | |
parent | js: fix file_name return on decrypt (diff) | |
download | gpgme-4f28fbddd3d70eb7e3ce874b1673630142110b72.tar.gz gpgme-4f28fbddd3d70eb7e3ce874b1673630142110b72.zip |
js: extend information on decoding in decrypt
--
* src/Connection.js: resulting data, if not pure ascii, is base64
encoded in the result message. A further decoding attempt into
javascript 'string' will be attempted by default, unless specified
at the decrypt() method. The return value 'format' now shows which
of the possibilities has been applied. The old boolean 'base64'
now turns into format:'base64' if the returned payload is a base64
string after decryption.
Diffstat (limited to 'lang/js')
-rw-r--r-- | lang/js/src/Connection.js | 4 | ||||
-rw-r--r-- | lang/js/src/gpgmejs.js | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/lang/js/src/Connection.js b/lang/js/src/Connection.js index 3fd1810d..c4921d53 100644 --- a/lang/js/src/Connection.js +++ b/lang/js/src/Connection.js @@ -232,7 +232,9 @@ class Answer{ return gpgme_error('CONN_UNEXPECTED_ANSWER'); } let _decodedResponse = JSON.parse(atob(this._response_b64)); - let _response = {}; + let _response = { + format: 'ascii' + }; let messageKeys = Object.keys(_decodedResponse); let poa = permittedOperations[this.operation].answer; if (messageKeys.length === 0){ diff --git a/lang/js/src/gpgmejs.js b/lang/js/src/gpgmejs.js index 5bdffeb5..b86b5f18 100644 --- a/lang/js/src/gpgmejs.js +++ b/lang/js/src/gpgmejs.js @@ -55,8 +55,12 @@ import { createSignature } from './Signature'; /** * @typedef {Object} encrypt_result The result of an encrypt operation * @property {String} data The encrypted message - * @property {Boolean} base64 Indicating whether returning payload data is - * base64 encoded + * @property {String} format Indicating how the data was converted after being + * received from gpgme. + * 'ascii': Data was ascii-encoded and no further processed + * 'string': Data was decoded into an utf-8 string, + * 'base64': Data was not processed and is a base64 string + * 'uint8': Data was turned into a Uint8Array */ /** |