From 352c53040d75e70dcda16c153d10c21e8eee0e01 Mon Sep 17 00:00:00 2001 From: Maximilian Krambach Date: Thu, 23 Aug 2018 12:30:49 +0200 Subject: [PATCH] js: offer an always-trust parameter on encrypt -- * src/gpgmejs.js: Setting the default to 'always trust' assumes that most api users will already have made their internal checks, but may not have the gnupg web-of-trust model implemented, thus trusting the key themselves, without gnupg having full or even any information. Still it should stay an option to have gnupg decide. --- lang/js/src/gpgmejs.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lang/js/src/gpgmejs.js b/lang/js/src/gpgmejs.js index ffee719c..1a5d5574 100644 --- a/lang/js/src/gpgmejs.js +++ b/lang/js/src/gpgmejs.js @@ -128,6 +128,9 @@ export class GpgME { * block. * @param {Boolean} options.wildcard (optional) If true, recipient * information will not be added to the message. + * @param {Boolean} always_trust (optional, default true) This assumes that + * used keys are fully trusted. If set to false, encryption to a key not + * fully trusted in gnupg will fail * @param {Object} additional use additional valid gpg options as * defined in {@link permittedOperations} * @returns {Promise} Object containing the encrypted @@ -135,7 +138,7 @@ export class GpgME { * @async */ encrypt ({ data, publicKeys, secretKeys, base64 = false, armor = true, - wildcard, additional = {} }){ + wildcard, always_trust = true, additional = {} }){ if (!data || !publicKeys){ return Promise.reject(gpgme_error('MSG_INCOMPLETE')); } @@ -148,6 +151,9 @@ export class GpgME { if (base64 === true) { msg.setParameter('base64', true); } + if (always_trust === true) { + msg.setParameter('always-trust', true); + } let pubkeys = toKeyIdArray(publicKeys); if (!pubkeys.length) { return Promise.reject(gpgme_error('MSG_NO_KEYS'));