aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/src/Key.js
diff options
context:
space:
mode:
authorMaximilian Krambach <[email protected]>2018-04-27 18:03:09 +0000
committerMaximilian Krambach <[email protected]>2018-04-27 18:03:09 +0000
commitfda7b13f1b673962ce34b6f429158a7eb9cef47b (patch)
tree8b1f828c451c2d04ac5e8b311b7df27552405c59 /lang/js/src/Key.js
parentjs: fixed empty operation setter in Message (diff)
downloadgpgme-fda7b13f1b673962ce34b6f429158a7eb9cef47b.tar.gz
gpgme-fda7b13f1b673962ce34b6f429158a7eb9cef47b.zip
js: more testing
-- * Tests: initialization of the two modes, encryption * gpgme.js: reintroduced message check before calling Connection.post() * gpgmejs_openpgp.js: Fixed openpgp mode not passing keys * index.js: fixed some confusion in parseconfig() * Inserted some TODO stubs for missing error handling
Diffstat (limited to 'lang/js/src/Key.js')
-rw-r--r--lang/js/src/Key.js23
1 files changed, 11 insertions, 12 deletions
diff --git a/lang/js/src/Key.js b/lang/js/src/Key.js
index 0b44b245..30449d63 100644
--- a/lang/js/src/Key.js
+++ b/lang/js/src/Key.js
@@ -51,10 +51,7 @@ export class GPGME_Key {
* hasSecret returns true if a secret subkey is included in this Key
*/
get hasSecret(){
- checkKey(this._fingerprint, 'secret').then( function(result){
- return Promise.resolve(result);
- });
-
+ return checkKey(this._fingerprint, 'secret');
}
get isRevoked(){
@@ -130,6 +127,8 @@ export class GPGME_Key {
}
}
return Promise.resolve(resultset);
+ }, function(error){
+ //TODO checkKey fails
});
}
@@ -175,8 +174,7 @@ export class GPGME_Key {
*/
function checkKey(fingerprint, property){
return Promise.reject(gpgme_error('NOT_YET_IMPLEMENTED'));
- if (!property ||
- permittedOperations[keyinfo].indexOf(property) < 0){
+ if (!property || !permittedOperations[keyinfo].hasOwnProperty(property)){
return Promise.reject(gpgme_error('PARAM_WRONG'));
}
return new Promise(function(resolve, reject){
@@ -188,19 +186,20 @@ function checkKey(fingerprint, property){
reject(gpgme_error('PARAM_WRONG'));
}
msg.setParameter('fingerprint', this.fingerprint);
- return (this.connection.post(msg)).then(function(result){
- if (result.hasOwnProperty(property)){
+ return (this.connection.post(msg)).then(function(result, error){
+ if (error){
+ reject(gpgme_error('GNUPG_ERROR',error.msg));
+ } else if (result.hasOwnProperty(property)){
resolve(result[property]);
}
else if (property == 'secret'){
- // TBD property undefined means "not true" in case of secret?
- resolve(false);
+ // TBD property undefined means "not true" in case of secret?
+ resolve(false);
} else {
reject(gpgme_error('CONN_UNEXPECTED_ANSWER'));
}
}, function(error){
- reject({code: 'GNUPG_ERROR',
- msg: error.msg});
+ //TODO error handling
});
});
}; \ No newline at end of file