js: update decrypt/verify results

--

* src/gpgmejs.js: Decrypt now parses additional optional dec_info
  information, as well as any verify information, if present

* src/permittedOperations: Now decrypt also expect the new return
  object dec_inf (containing info such as is_mime and file_name)
This commit is contained in:
Maximilian Krambach 2018-08-21 15:26:17 +02:00
parent 9dd6c67cd5
commit 6d720137dd
4 changed files with 49 additions and 12 deletions

View File

@ -59,4 +59,20 @@ describe('Decryption', function () {
});
});
}).timeout(5000);
it('decrypt/verify operations return proper information', function (done){
const data = inputvalues.encryptSignedMessage;
context.decrypt(data).then(function (result){
expect(result).to.be.an('object');
expect(result.signatures).to.be.an('object');
expect(result.signatures.all_valid).to.be.true;
expect(result.signatures.count).to.equal(1);
expect(result.signatures.signatures.good).to.be.an('array');
expect(
result.signatures.signatures.good[0].fingerprint).to.equal(
good_fpr);
done();
});
});
});

View File

@ -86,9 +86,27 @@ const inputvalues = {// eslint-disable-line no-unused-vars
'CfhY40nMXSYdfl8mDOhvnKcCvy8qxetFv9uCX06OqepAamu/bvxslrzocRyJ/eq0\n' +
'T2JfzEN+E7Y3PB8UwLgp/ZRmG8zRrQ==\n' +
'=ioB6\n' +
'-----END PGP SIGNATURE-----\n',
'-----END PGP SIGNATURE-----\n'
},
encryptSignedMessage: '-----BEGIN PGP MESSAGE-----\n'+
'\n'+
'hQEMA6B8jfIUScGEAQf/bmQ+xNMGTjPvQCktkxR4Svt2dVNVdSzKsCmvSv24QOQF\n'+
'yBMK5w51S/6DTdiZI12IYD7hjvkr9NqxXXupjrVKwqEVpg4Pkwckac0OcElJIBsL\n'+
'3htr4iYsr8dhSgSS4BO0azcu4wZQTXy5v2P7yYPECMEagNEXnW+tE7sHLCq8Ysqz\n'+
'LVxG0R0IUijKeEd3xQC2Tt20e1Z1j5tnqaPhE/9Smqf5OjSUDqpXxvRnSNRk/zEs\n'+
'cGVgCF+cv68nUJM9lwEAbBQChplwL6ebnhunC6DsRCxnjLHVyKm127hmhSiMGC0e\n'+
'Ns31mGeP1dxpDv6Gi2/oKmq67vG3i4fKeckj7bt30tLA1wH0Qn5Mn6Tzxzve0W0q\n'+
'Ghqn9PY9qNK8EkrkzqaFk9dzu5tfSbaJBLS/uIhX2Wj70EMEBbFSkN0qlgOfLgGw\n'+
'5mwRvCgj4nvV1ByFhnx7uwgQixvOwLH4JLKvwCQpJm+O2R0eC7M6CzR/b9iL/oaO\n'+
'JTkoD9hcLhxF7j+3ZYg7rbNwofuHST097vFjzItsucb0jHOzjlkCqbhdczICILTa\n'+
'H76Q6YGdMLyG9a3s4yZUMruaeQyWGeXlryzLDvdEoSgoD5YrolsFOM+Z2apbzVs2\n'+
'k5CltwtanjjWGnpAqSyr49C6CSU8G1QHpNygx5frtAS8bojR2ovB9OJp2wUklDvC\n'+
'LtU7dLpTY/BIvfB1vzwcW/aNgmPadNHX8mAzlqTQJjeLoo69Wp804t+u36sgfd/J\n'+
'ser7vdJJUm+86Q9csefItvFmHhqjMg5XXHoa8WZWJOHIQMxZkaIwKAzcEt/oEOdJ\n'+
'rbVNVabhTdbmS5I1ok16wg5jMF07ZDM7nXWMcQNjwT646XKP+pp2N6YQROVidNXj\n'+
'COyRyiXE/csr\n'+
'=Ik7G\n'+
'-----END PGP MESSAGE-----\n',
someInputParameter: 'bad string',
publicKeyNonAscii: {

View File

@ -192,18 +192,21 @@ export class GpgME {
msg.post().then(function (result){
let _result = { data: result.data };
_result.base64 = result.base64 ? true: false;
_result.is_mime = result.is_mime ? true: false;
if (result.file_name){
_result.file_name = result.file_name;
} else {
if (result.hasOwnProperty('dec_info')){
_result.is_mime = result.dec_info.is_mime ? true: false;
if (result.dec_info.file_name) {
_result.file_name = result.dec_info.file_name;
}
}
if (!result.file_name) {
_result.file_name = null;
}
if (
result.hasOwnProperty('signatures') &&
Array.isArray(result.signatures)
if (result.hasOwnProperty('info')
&& result.info.hasOwnProperty('signatures')
&& Array.isArray(result.info.signatures)
) {
_result.signatures = collectSignatures(
result.signatures);
result.info.signatures);
}
resolve(_result);
}, function (error){

View File

@ -127,8 +127,8 @@ export const permittedOperations = {
'data': 'string',
'base64': 'boolean',
'mime': 'boolean',
'signatures': 'object',
'info': 'object'
'info': 'object',
'dec_info': 'object'
}
}
},