aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/src/Keyring.js
diff options
context:
space:
mode:
authorMaximilian Krambach <[email protected]>2018-05-30 15:05:54 +0000
committerMaximilian Krambach <[email protected]>2018-05-30 15:05:54 +0000
commit332b4adbcc52ccf337cbc1943d5abef500769e10 (patch)
tree4772742bc9ac61faabcfcc5d5ad5b635e725b614 /lang/js/src/Keyring.js
parentjs: Keyring listing keys (diff)
downloadgpgme-332b4adbcc52ccf337cbc1943d5abef500769e10.tar.gz
gpgme-332b4adbcc52ccf337cbc1943d5abef500769e10.zip
js: more Keyring/Key handling
-- * src/Keys.js - made setKeyData more consistent with other methods - added convenience methods (Key.armored, Key.hasSecret) - Added a Key delete function * src/Keyring.js: - added a getkeysArmored which allows for bulk export of public Keys gpgmejs: - removed deleteKey. It is now a method of the Key itself - Encrypt: Added some common options as parameter, and the possibility to set all allowed flags via an additional Object
Diffstat (limited to '')
-rw-r--r--lang/js/src/Keyring.js32
1 files changed, 26 insertions, 6 deletions
diff --git a/lang/js/src/Keyring.js b/lang/js/src/Keyring.js
index 7e13dfe2..9081cbe9 100644
--- a/lang/js/src/Keyring.js
+++ b/lang/js/src/Keyring.js
@@ -20,7 +20,7 @@
import {createMessage} from './Message'
import {GPGME_Key, createKey} from './Key'
-import { isFingerprint } from './Helpers';
+import { isFingerprint, toKeyIdArray } from './Helpers';
import { gpgme_error } from './Errors';
export class GPGME_Keyring {
@@ -43,10 +43,10 @@ export class GPGME_Keyring {
return new Promise(function(resolve, reject) {
let msg;
msg = createMessage('keylist');
- if (pattern && typeof(pattern) === 'string'){
+ if (pattern !== undefined){
msg.setParameter('keys', pattern);
}
- msg.setParameter('sigs', true); //TODO do we need this?
+ msg.setParameter('sigs', true);
msg.post().then(function(result){
let resultset = [];
let promises = [];
@@ -72,10 +72,30 @@ export class GPGME_Keyring {
});
});
}
-// TODO:
- // deleteKey(key, include_secret=false)
- // getKeysArmored(pattern) //just dump all armored keys
+
+ /**
+ * Fetches the armored public Key blocks for all Keys matchin the pattern
+ * (if no pattern is given, fetches all known to gnupg)
+ * @param {String|Array<String>} pattern (optional)
+ * @returns {Promise<String>} Armored Key blocks
+ */
+ getKeysArmored(pattern) {
+ if (pattern)
+ return new Promise(function(resolve, reject) {
+ let msg = createMessage('export');
+ msg.setParameter('armor', true);
+ if (pattern !== undefined){
+ msg.setParameter('keys', pattern);
+ }
+ msg.post().then(function(result){
+ resolve(result.data);
+ }, function(error){
+ reject(error);
+ });
+ }
+
// getDefaultKey() Big TODO
// importKeys(armoredKeys)
+ // generateKey --> TODO (Andre noch anfragen!)
};