[git] GPGME - branch, javascript-binding, updated. gpgme-1.11.1-73-g30bb549
by Maximilian Krambach
cvs at cvs.gnupg.org
Thu Jul 12 11:42:11 CEST 2018
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".
The branch, javascript-binding has been updated
via 30bb5490466119b66eeac255d71fb7bdc79149fa (commit)
from 4015f5b4983c8a4590aa71776880d8bc42c7918d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 30bb5490466119b66eeac255d71fb7bdc79149fa
Author: Maximilian Krambach <maximilian.krambach at intevation.de>
Date: Thu Jul 12 11:36:55 2018 +0200
js: add with-sec-fprs to getKeysArmored
--
* Reflects the changes made to gpgme-json in commit
6cc842c9aa76d19448141e5117ac59452d7a1ff3.
- getKeysArmored now returns an object with property 'armored' being
the exported armored block, and an (optional) array of fingerprint
strings for those keys that can be used in sign/encrypt operations
as property 'secret_fprs'. With this, extensions such as mailvelope
will be able to bulk fetch all necessary key information in one
request.
diff --git a/lang/js/BrowserTestExtension/tests/KeyImportExport.js b/lang/js/BrowserTestExtension/tests/KeyImportExport.js
index 33e6bd2..4a53c7a 100644
--- a/lang/js/BrowserTestExtension/tests/KeyImportExport.js
+++ b/lang/js/BrowserTestExtension/tests/KeyImportExport.js
@@ -22,7 +22,7 @@
* Raimund Renkert <rrenkert at intevation.de>
*/
-/* global describe, it, expect, Gpgmejs, ImportablePublicKey */
+/* global describe, it, expect, Gpgmejs, ImportablePublicKey, inputvalues */
describe('Key importing', function () {
it('Prepare test Key (deleting it from gnupg, if present)', function(done){
@@ -83,5 +83,30 @@ describe('Key importing', function () {
});
});
});
-
+ it('exporting armored Key with getKeysArmored', function (done) {
+ let prm = Gpgmejs.init();
+ const fpr = inputvalues.encrypt.good.fingerprint;
+ prm.then(function (context) {
+ context.Keyring.getKeysArmored(fpr).then(function(result){
+ expect(result).to.be.an('object');
+ expect(result.armored).to.be.a('string');
+ expect(result.secret_fprs).to.be.undefined;
+ done();
+ });
+ });
+ });
+ it('exporting armored Key (including secret fingerprints) with '
+ + 'getKeysArmored', function (done) {
+ let prm = Gpgmejs.init();
+ const fpr = inputvalues.encrypt.good.fingerprint;
+ prm.then(function (context) {
+ context.Keyring.getKeysArmored(fpr, true).then(function(result){
+ expect(result).to.be.an('object');
+ expect(result.armored).to.be.a('string');
+ expect(result.secret_fprs).to.be.an('array');
+ expect(result.secret_fprs[0]).to.equal(fpr);
+ done();
+ });
+ });
+ });
});
\ No newline at end of file
diff --git a/lang/js/src/Keyring.js b/lang/js/src/Keyring.js
index a0bdfcb..7a33be9 100644
--- a/lang/js/src/Keyring.js
+++ b/lang/js/src/Keyring.js
@@ -108,25 +108,45 @@ export class GPGME_Keyring {
}
/**
+ * @typedef {Object} exportResult The result of a getKeysArmored operation.
+ * @property {String} armored The public Key(s) as armored block. Note that
+ * the result is one armored block, and not a block per key.
+ * @property {Array<String>} secret_fprs (optional) list of fingerprints
+ * for those Keys that also have a secret Key available in gnupg. The
+ * secret key will not be exported, but the fingerprint can be used in
+ * operations needing a secret key.
+ */
+
+ /**
* Fetches the armored public Key blocks for all Keys matching the pattern
- * (if no pattern is given, fetches all keys known to gnupg). Note that the
- * result may be one big armored block, instead of several smaller armored
- * blocks
+ * (if no pattern is given, fetches all keys known to gnupg).
* @param {String|Array<String>} pattern (optional) The Pattern to search
* for
- * @returns {Promise<String|GPGME_Error>} Armored Key blocks
+ * @param {Boolean} with_secret_fpr (optional) also return a list of
+ * fingerprints for the keys that have a secret key available
+ * @returns {Promise<exportResult|GPGME_Error>} Object containing the
+ * armored Key(s) and additional information.
* @static
* @async
*/
- getKeysArmored(pattern) {
+ getKeysArmored(pattern, with_secret_fpr) {
return new Promise(function(resolve, reject) {
let msg = createMessage('export');
msg.setParameter('armor', true);
+ if (with_secret_fpr === true) {
+ msg.setParameter('with-sec-fprs', true);
+ }
if (pattern !== undefined){
msg.setParameter('keys', pattern);
}
- msg.post().then(function(result){
- resolve(result.data);
+ msg.post().then(function(answer){
+ const result = {armored: answer.data};
+ if (with_secret_fpr === true
+ && answer.hasOwnProperty('sec-fprs')
+ ) {
+ result.secret_fprs = answer['sec-fprs'];
+ }
+ resolve(result);
}, function(error){
reject(error);
});
diff --git a/lang/js/src/permittedOperations.js b/lang/js/src/permittedOperations.js
index 0b9c891..b5e9157 100644
--- a/lang/js/src/permittedOperations.js
+++ b/lang/js/src/permittedOperations.js
@@ -246,7 +246,10 @@ export const permittedOperations = {
'raw': {
allowed: ['boolean']
},
- 'pkcs12':{
+ 'pkcs12': {
+ allowed: ['boolean']
+ },
+ 'with-sec-fprs': {
allowed: ['boolean']
}
// secret: not yet implemented
@@ -255,7 +258,8 @@ export const permittedOperations = {
type: ['keys'],
data: {
'data': 'string',
- 'base64': 'boolean'
+ 'base64': 'boolean',
+ 'sec-fprs': 'object'
}
}
},
@@ -295,10 +299,6 @@ export const permittedOperations = {
allowed: ['string'],
allowed_data: ['cms', 'openpgp']
},
- // 'secret': { not implemented
- // allowed: ['boolean']
- // }
-
},
answer: {
data: {
-----------------------------------------------------------------------
Summary of changes:
.../BrowserTestExtension/tests/KeyImportExport.js | 29 ++++++++++++++++--
lang/js/src/Keyring.js | 34 +++++++++++++++++-----
lang/js/src/permittedOperations.js | 12 ++++----
3 files changed, 60 insertions(+), 15 deletions(-)
hooks/post-receive
--
GnuPG Made Easy
http://git.gnupg.org
More information about the Gnupg-commits
mailing list