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.
This commit is contained in:
Maximilian Krambach 2018-08-27 11:50:09 +02:00
parent 557fec6002
commit 4f28fbddd3
2 changed files with 9 additions and 3 deletions

View File

@ -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){

View File

@ -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
*/
/**