js: fix indentaion

--

* doing the indentation changes that became neccesary in the last
  commit.
This commit is contained in:
Maximilian Krambach 2018-07-27 20:56:11 +02:00
parent 94ee0988d4
commit 522121ea7e
6 changed files with 1187 additions and 1175 deletions

View File

@ -98,9 +98,9 @@ export class Connection{
}; };
/** /**
* Sends a {@link GPGME_Message} via tghe nativeMessaging port. It resolves * Sends a {@link GPGME_Message} via tghe nativeMessaging port. It
* with the completed answer after all parts have been received and * resolves with the completed answer after all parts have been
* reassembled, or rejects with an {@link GPGME_Error}. * received and reassembled, or rejects with an {@link GPGME_Error}.
* *
* @param {GPGME_Message} message * @param {GPGME_Message} message
* @returns {Promise<Object>} The collected answer * @returns {Promise<Object>} The collected answer
@ -173,7 +173,7 @@ export class Connection{
} }
}); });
}; };
} }
} }
/** /**
@ -197,6 +197,7 @@ class Answer{
this.getExpect = function(){ this.getExpect = function(){
return expect; return expect;
}; };
/** /**
* Adds incoming base64 encoded data to the existing response * Adds incoming base64 encoded data to the existing response
* @param {*} msg base64 encoded data. * @param {*} msg base64 encoded data.
@ -217,8 +218,8 @@ class Answer{
} }
}; };
/** /**
* Returns the base64 encoded answer data with the content verified against * Returns the base64 encoded answer data with the content verified
* {@link permittedOperations}. * against {@link permittedOperations}.
*/ */
this.getMessage = function (){ this.getMessage = function (){
if (response_b64 === undefined){ if (response_b64 === undefined){
@ -246,7 +247,8 @@ class Answer{
break; break;
case 'msg': case 'msg':
if (_decodedResponse.type === 'error'){ if (_decodedResponse.type === 'error'){
return (gpgme_error('GNUPG_ERROR', _decodedResponse.msg)); return (gpgme_error('GNUPG_ERROR',
_decodedResponse.msg));
} }
break; break;
default: default:
@ -274,5 +276,5 @@ class Answer{
} }
return _response; return _response;
}; };
} }
} }

View File

@ -67,9 +67,10 @@ export class GPGME_Key {
}; };
/** /**
* Property indicating if the Key possesses a private/secret part. If this * Property indicating if the Key possesses a private/secret part. If
* information is not yet cached, it returns an {@link GPGME_Error} with * this information is not yet cached, it returns an
* code 'KEY_NO_INIT'. Running {@link refreshKey} may help in this case. * {@link GPGME_Error} with code 'KEY_NO_INIT'. Running
* {@link refreshKey} may help in this case.
* @returns {Boolean} If the Key has a secret subkey. * @returns {Boolean} If the Key has a secret subkey.
*/ */
this.hasSecret= function (){ this.hasSecret= function (){
@ -77,10 +78,10 @@ export class GPGME_Key {
}; };
/** /**
* @param {Object} data Bulk set the data for this key, with an Object sent * @param {Object} data Bulk set the data for this key, with an Object
* by gpgme-json. * sent by gpgme-json.
* @returns {GPGME_Key|GPGME_Error} Itself after values have been set, an * @returns {GPGME_Key|GPGME_Error} Itself after values have been set,
* error if something went wrong * an error if something went wrong.
* @private * @private
*/ */
this.setKeyData = function (data){ this.setKeyData = function (data){
@ -168,10 +169,10 @@ export class GPGME_Key {
}; };
/** /**
* Reloads the Key information from gnupg. This is only useful if you use * Reloads the Key information from gnupg. This is only useful if you
* the GPGME_Keys cached. Note that this is a performance hungry operation. * use the GPGME_Keys cached. Note that this is a performance hungry
* If you desire more than a few refreshs, it may be advisable to run * operation. If you desire more than a few refreshs, it may be
* {@link Keyring.getKeys} instead. * advisable to run {@link Keyring.getKeys} instead.
* @returns {Promise<GPGME_Key|GPGME_Error>} * @returns {Promise<GPGME_Key|GPGME_Error>}
* @async * @async
*/ */
@ -206,8 +207,9 @@ export class GPGME_Key {
}; };
/** /**
* Query the armored block of the Key directly from gnupg. Please note that * Query the armored block of the Key directly from gnupg. Please note
* this will not get you any export of the secret/private parts of a Key * that this will not get you any export of the secret/private parts of
* a Key
* @returns {Promise<String|GPGME_Error>} * @returns {Promise<String|GPGME_Error>}
* @async * @async
*/ */
@ -229,12 +231,12 @@ export class GPGME_Key {
}; };
/** /**
* Find out if the Key includes a secret part. Note that this is a rather * Find out if the Key includes a secret part. Note that this is a
* nonperformant operation, as it needs to query gnupg twice. If you want * rather nonperformant operation, as it needs to query gnupg twice.
* this inforrmation about more than a few Keys, it may be advisable to run * If you want this inforrmation about more than a few Keys, it may be
* {@link Keyring.getKeys} instead. * advisable to run {@link Keyring.getKeys} instead.
* @returns {Promise<Boolean|GPGME_Error>} True if a secret/private Key is * @returns {Promise<Boolean|GPGME_Error>} True if a secret/private Key
* available in the gnupg Keyring * is available in the gnupg Keyring
* @async * @async
*/ */
this.getHasSecret = function (){ this.getHasSecret = function (){
@ -265,8 +267,8 @@ export class GPGME_Key {
}; };
/** /**
* Deletes the (public) Key from the GPG Keyring. Note that a deletion of a * Deletes the (public) Key from the GPG Keyring. Note that a deletion
* secret key is not supported by the native backend. * of a secret key is not supported by the native backend.
* @returns {Promise<Boolean|GPGME_Error>} Success if key was deleted, * @returns {Promise<Boolean|GPGME_Error>} Success if key was deleted,
* rejects with a GPG error otherwise. * rejects with a GPG error otherwise.
*/ */
@ -342,8 +344,6 @@ class GPGME_Subkey {
setProperty(keys[i], data[keys[i]]); setProperty(keys[i], data[keys[i]]);
} }
/** /**
* Fetches any information about this subkey * Fetches any information about this subkey
* @param {String} property Information to request * @param {String} property Information to request
@ -354,8 +354,7 @@ class GPGME_Subkey {
return (_data[property]); return (_data[property]);
} }
}; };
} }
} }
/** /**
@ -407,9 +406,9 @@ class GPGME_UserId {
return (_data[property]); return (_data[property]);
} }
}; };
}
} }
}
/** /**
* Validation definition for userIds. Each valid userId property is represented * Validation definition for userIds. Each valid userId property is represented
* as a key- Value pair, with their value being a validation function to check * as a key- Value pair, with their value being a validation function to check

View File

@ -36,15 +36,16 @@ export class GPGME_Keyring {
/** /**
* Queries Keys (all Keys or a subset) from gnupg. * Queries Keys (all Keys or a subset) from gnupg.
* *
* @param {String | Array<String>} pattern (optional) A pattern to search * @param {String | Array<String>} pattern (optional) A pattern to
* for in userIds or KeyIds. * search for in userIds or KeyIds.
* @param {Boolean} prepare_sync (optional) if set to true, the 'hasSecret' * @param {Boolean} prepare_sync (optional) if set to true, the
* and 'armored' properties will be fetched for the Keys as well. These * 'hasSecret' and 'armored' properties will be fetched for the Keys as
* require additional calls to gnupg, resulting in a performance hungry * well. These require additional calls to gnupg, resulting in a
* operation. Calling them here enables direct, synchronous use of these * performance hungry operation. Calling them here enables direct,
* properties for all keys, without having to resort to a refresh() first. * synchronous use of these properties for all keys, without having to
* @param {Boolean} search (optional) retrieve Keys from external servers * resort to a refresh() first.
* with the method(s) defined in gnupg (e.g. WKD/HKP lookup) * @param {Boolean} search (optional) retrieve Keys from external
* servers with the method(s) defined in gnupg (e.g. WKD/HKP lookup)
* @returns {Promise.<Array<GPGME_Key>|GPGME_Error>} * @returns {Promise.<Array<GPGME_Key>|GPGME_Error>}
* @static * @static
* @async * @async
@ -82,12 +83,15 @@ export class GPGME_Keyring {
if (prepare_sync === true){ if (prepare_sync === true){
result.keys[i].hasSecret = false; result.keys[i].hasSecret = false;
if (answer && answer.keys) { if (answer && answer.keys) {
for (let j=0; j < answer.keys.length; j++ ){ for (let j=0;
if (result.keys[i].fingerprint === j < answer.keys.length; j++ ){
answer.keys[j].fingerprint const a = answer.keys[j];
const b = result.keys[i];
if (
a.fingerprint === b.fingerprint
) { ) {
if (answer.keys[j].secret === true){ if (a.secret === true){
result.keys[i].hasSecret = true; a.hasSecret = true;
} }
break; break;
} }
@ -109,20 +113,21 @@ export class GPGME_Keyring {
}; };
/** /**
* @typedef {Object} exportResult The result of a getKeysArmored operation. * @typedef {Object} exportResult The result of a getKeysArmored
* @property {String} armored The public Key(s) as armored block. Note that * operation.
* the result is one armored block, and not a block per key. * @property {String} armored The public Key(s) as armored block. Note
* @property {Array<String>} secret_fprs (optional) list of fingerprints * that the result is one armored block, and not a block per key.
* for those Keys that also have a secret Key available in gnupg. The * @property {Array<String>} secret_fprs (optional) list of
* secret key will not be exported, but the fingerprint can be used in * fingerprints for those Keys that also have a secret Key available in
* operations needing a secret key. * 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 * Fetches the armored public Key blocks for all Keys matching the
* (if no pattern is given, fetches all keys known to gnupg). * pattern (if no pattern is given, fetches all keys known to gnupg).
* @param {String|Array<String>} pattern (optional) The Pattern to search * @param {String|Array<String>} pattern (optional) The Pattern to
* for * search for
* @param {Boolean} with_secret_fpr (optional) also return a list of * @param {Boolean} with_secret_fpr (optional) also return a list of
* fingerprints for the keys that have a secret key available * fingerprints for the keys that have a secret key available
* @returns {Promise<exportResult|GPGME_Error>} Object containing the * @returns {Promise<exportResult|GPGME_Error>} Object containing the
@ -157,8 +162,8 @@ export class GPGME_Keyring {
/** /**
* Returns the Key used by default in gnupg. * Returns the Key used by default in gnupg.
* (a.k.a. 'primary Key or 'main key'). * (a.k.a. 'primary Key or 'main key').
* It looks up the gpg configuration if set, or the first key that contains * It looks up the gpg configuration if set, or the first key that
* a secret key. * contains a secret key.
* *
* @returns {Promise<GPGME_Key|GPGME_Error>} * @returns {Promise<GPGME_Key|GPGME_Error>}
* @async * @async
@ -175,7 +180,8 @@ export class GPGME_Keyring {
&& response.value.hasOwnProperty('string') && response.value.hasOwnProperty('string')
&& typeof(response.value.string) === 'string' && typeof(response.value.string) === 'string'
){ ){
me.getKeys(response.value.string,true).then(function(keys){ me.getKeys(response.value.string,true).then(
function(keys){
if(keys.length === 1){ if(keys.length === 1){
resolve(keys[0]); resolve(keys[0]);
} else { } else {
@ -224,7 +230,8 @@ export class GPGME_Keyring {
* @property {GPGME_Key} key The resulting key * @property {GPGME_Key} key The resulting key
* @property {String} status: * @property {String} status:
* 'nochange' if the Key was not changed, * 'nochange' if the Key was not changed,
* 'newkey' if the Key was imported in gpg, and did not exist previously, * 'newkey' if the Key was imported in gpg, and did not exist
* previously,
* 'change' if the key existed, but details were updated. For details, * 'change' if the key existed, but details were updated. For details,
* Key.changes is available. * Key.changes is available.
* @property {Boolean} changes.userId Changes in userIds * @property {Boolean} changes.userId Changes in userIds
@ -233,10 +240,10 @@ export class GPGME_Keyring {
*/ */
/** /**
* Import an armored Key block into gnupg. Note that this currently will * Import an armored Key block into gnupg. Note that this currently
* not succeed on private Key blocks. * will not succeed on private Key blocks.
* @param {String} armored Armored Key block of the Key(s) to be imported * @param {String} armored Armored Key block of the Key(s) to be
* into gnupg * imported into gnupg
* @param {Boolean} prepare_sync prepare the keys for synched use * @param {Boolean} prepare_sync prepare the keys for synched use
* (see {@link getKeys}). * (see {@link getKeys}).
* @returns {Promise<importResult>} A summary and Keys considered. * @returns {Promise<importResult>} A summary and Keys considered.
@ -287,7 +294,8 @@ export class GPGME_Keyring {
for (let i=0; i < result.length; i++) { for (let i=0; i < result.length; i++) {
resultset.push({ resultset.push({
key: result[i], key: result[i],
changes: infos[result[i].fingerprint].changes, changes:
infos[result[i].fingerprint].changes,
status: infos[result[i].fingerprint].status status: infos[result[i].fingerprint].status
}); });
} }
@ -343,14 +351,15 @@ export class GPGME_Keyring {
/** /**
* Generates a new Key pair directly in gpg, and returns a GPGME_Key * Generates a new Key pair directly in gpg, and returns a GPGME_Key
* representing that Key. Please note that due to security concerns, secret * representing that Key. Please note that due to security concerns,
* Keys can not be deleted or exported from inside gpgme.js. * secret Keys can not be deleted or exported from inside gpgme.js.
* *
* @param {String} userId The user Id, e.g. 'Foo Bar <foo@bar.baz>' * @param {String} userId The user Id, e.g. 'Foo Bar <foo@bar.baz>'
* @param {String} algo (optional) algorithm (and optionally key size) to * @param {String} algo (optional) algorithm (and optionally key size)
* be used. See {@link supportedKeyAlgos} below for supported values. * to be used. See {@link supportedKeyAlgos} below for supported
* @param {Date} expires (optional) Expiration date. If not set, expiration * values.
* will be set to 'never' * @param {Date} expires (optional) Expiration date. If not set,
* expiration will be set to 'never'
* *
* @return {Promise<Key|GPGME_Error>} * @return {Promise<Key|GPGME_Error>}
* @async * @async
@ -374,7 +383,7 @@ export class GPGME_Keyring {
} }
msg.post().then(function(response){ msg.post().then(function(response){
me.getKeys(response.fingerprint, true).then( me.getKeys(response.fingerprint, true).then(
// TODO make prepare_sync (second parameter) optional here. // TODO prepare_sync?
function(result){ function(result){
resolve(result); resolve(result);
}, function(error){ }, function(error){
@ -385,7 +394,7 @@ export class GPGME_Keyring {
}); });
}); });
}; };
} }
} }
/** /**

View File

@ -63,12 +63,12 @@ export class GPGME_Message {
/** /**
* The maximum size of responses from gpgme in bytes. As of July 2018, * The maximum size of responses from gpgme in bytes. As of July 2018,
* most browsers will only accept answers up to 1 MB of size. Everything * most browsers will only accept answers up to 1 MB of size.
* above that threshold will not pass through nativeMessaging; answers that * Everything above that threshold will not pass through
* are larger need to be sent in parts. The lower limit is set to 10 KB. * nativeMessaging; answers that are larger need to be sent in parts.
* Messages smaller than the threshold will not encounter problems, larger * The lower limit is set to 10 KB. Messages smaller than the threshold
* messages will be received in chunks. * will not encounter problems, larger messages will be received in
* If the value is not explicitly specified, 1023 KB is used. * chunks. If the value is not explicitly specified, 1023 KB is used.
*/ */
this.setChunksize = function (value){ this.setChunksize = function (value){
if ( if (
@ -216,7 +216,7 @@ export class GPGME_Message {
} }
}); });
}; };
} }
/** /**
* Returns the prepared message with parameters and completeness checked * Returns the prepared message with parameters and completeness checked
@ -231,11 +231,10 @@ export class GPGME_Message {
return null; return null;
} }
} }
get operation(){
get operation(){
return this.getOperation(); return this.getOperation();
} }
get chunksize(){ get chunksize(){
return this.getChunksize(); return this.getChunksize();
} }
} }

View File

@ -114,7 +114,7 @@ class GPGME_Signature {
/** /**
* The overall validity of the key. If false, errorDetails may contain * The overall validity of the key. If false, errorDetails may contain
* additional information * additional information.
*/ */
this.getValid= function() { this.getValid= function() {
if (_rawSigObject.summary.valid === true){ if (_rawSigObject.summary.valid === true){
@ -125,9 +125,9 @@ class GPGME_Signature {
}; };
/** /**
* gives more information on non-valid signatures. Refer to the gpgme docs * gives more information on non-valid signatures. Refer to the gpgme
* https://www.gnupg.org/documentation/manuals/gpgme/Verify.html for * docs https://www.gnupg.org/documentation/manuals/gpgme/Verify.html
* details on the values * for details on the values.
* @returns {Object} Object with boolean properties * @returns {Object} Object with boolean properties
*/ */
this.getErrorDetails = function (){ this.getErrorDetails = function (){
@ -142,7 +142,7 @@ class GPGME_Signature {
} }
return result; return result;
}; };
} }
/** /**
* Convenience getter for {@link getFingerprint} * Convenience getter for {@link getFingerprint}

View File

@ -113,16 +113,17 @@ export class GpgME {
* accepts Objects with a getText method * accepts Objects with a getText method
* @param {inputKeys} publicKeys * @param {inputKeys} publicKeys
* Keys used to encrypt the message * Keys used to encrypt the message
* @param {inputKeys} secretKeys (optional) Keys used to sign the message. * @param {inputKeys} secretKeys (optional) Keys used to sign the
* If Keys are present, the operation requested is assumed to be 'encrypt * message. If Keys are present, the operation requested is assumed
* and sign' * to be 'encrypt and sign'
* @param {Boolean} base64 (optional) The data will be interpreted as * @param {Boolean} base64 (optional) The data will be interpreted as
* base64 encoded data. * base64 encoded data.
* @param {Boolean} armor (optional) Request the output as armored block. * @param {Boolean} armor (optional) Request the output as armored
* @param {Boolean} wildcard (optional) If true, recipient information will * block.
* not be added to the message. * @param {Boolean} wildcard (optional) If true, recipient information
* @param {Object} additional use additional valid gpg options as defined * will not be added to the message.
* in {@link permittedOperations} * @param {Object} additional use additional valid gpg options as
* defined in {@link permittedOperations}
* @returns {Promise<encrypt_result>} Object containing the encrypted * @returns {Promise<encrypt_result>} Object containing the encrypted
* message and additional info. * message and additional info.
* @async * @async
@ -165,10 +166,10 @@ export class GpgME {
/** /**
* Decrypts a Message * Decrypts a Message
* @param {String|Object} data text/data to be decrypted. Accepts Strings * @param {String|Object} data text/data to be decrypted. Accepts
* and Objects with a getText method * Strings and Objects with a getText method
* @param {Boolean} base64 (optional) false if the data is an armored block, * @param {Boolean} base64 (optional) false if the data is an armored
* true if it is base64 encoded binary data * block, true if it is base64 encoded binary data
* @returns {Promise<decrypt_result>} Decrypted Message and information * @returns {Promise<decrypt_result>} Decrypted Message and information
* @async * @async
*/ */
@ -200,7 +201,8 @@ export class GpgME {
result.hasOwnProperty('signatures') && result.hasOwnProperty('signatures') &&
Array.isArray(result.signatures) Array.isArray(result.signatures)
) { ) {
_result.signatures = collectSignatures(result.signatures); _result.signatures = collectSignatures(
result.signatures);
} }
resolve(_result); resolve(_result);
}, function(error){ }, function(error){
@ -262,8 +264,8 @@ export class GpgME {
* Verifies data. * Verifies data.
* @param {String|Object} data text/data to be verified. Accepts Strings * @param {String|Object} data text/data to be verified. Accepts Strings
* and Objects with a getText method * and Objects with a getText method
* @param {String} (optional) A detached signature. If not present, opaque * @param {String} (optional) A detached signature. If not present,
* mode is assumed * opaque mode is assumed
* @param {Boolean} (optional) Data and signature are base64 encoded * @param {Boolean} (optional) Data and signature are base64 encoded
* @returns {Promise<verifyResult>} * @returns {Promise<verifyResult>}
*@async *@async
@ -289,7 +291,8 @@ export class GpgME {
if (!message.info || !message.info.signatures){ if (!message.info || !message.info.signatures){
reject(gpgme_error('SIG_NO_SIGS')); reject(gpgme_error('SIG_NO_SIGS'));
} else { } else {
let _result = collectSignatures(message.info.signatures); let _result = collectSignatures(
message.info.signatures);
_result.is_mime = message.info.is_mime? true: false; _result.is_mime = message.info.is_mime? true: false;
if (message.info.filename){ if (message.info.filename){
_result.file_name = message.info.filename; _result.file_name = message.info.filename;
@ -302,7 +305,7 @@ export class GpgME {
}); });
}); });
}; };
} }
/** /**
* setter for {@link setKeyring}. * setter for {@link setKeyring}.
@ -332,7 +335,7 @@ export class GpgME {
* @private * @private
*/ */
function putData(message, data){ function putData(message, data){
if (!message || !message instanceof GPGME_Message) { if (!message || !(message instanceof GPGME_Message)) {
return gpgme_error('PARAM_WRONG'); return gpgme_error('PARAM_WRONG');
} }
if (!data){ if (!data){