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

View File

@ -67,9 +67,10 @@ export class GPGME_Key {
};
/**
* Property indicating if the Key possesses a private/secret part. If this
* information is not yet cached, it returns an {@link GPGME_Error} with
* code 'KEY_NO_INIT'. Running {@link refreshKey} may help in this case.
* Property indicating if the Key possesses a private/secret part. If
* this information is not yet cached, it returns an
* {@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.
*/
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
* by gpgme-json.
* @returns {GPGME_Key|GPGME_Error} Itself after values have been set, an
* error if something went wrong
* @param {Object} data Bulk set the data for this key, with an Object
* sent by gpgme-json.
* @returns {GPGME_Key|GPGME_Error} Itself after values have been set,
* an error if something went wrong.
* @private
*/
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
* the GPGME_Keys cached. Note that this is a performance hungry operation.
* If you desire more than a few refreshs, it may be advisable to run
* {@link Keyring.getKeys} instead.
* Reloads the Key information from gnupg. This is only useful if you
* use the GPGME_Keys cached. Note that this is a performance hungry
* operation. If you desire more than a few refreshs, it may be
* advisable to run {@link Keyring.getKeys} instead.
* @returns {Promise<GPGME_Key|GPGME_Error>}
* @async
*/
@ -206,8 +207,9 @@ export class GPGME_Key {
};
/**
* Query the armored block of the Key directly from gnupg. Please note that
* this will not get you any export of the secret/private parts of a Key
* Query the armored block of the Key directly from gnupg. Please note
* that this will not get you any export of the secret/private parts of
* a Key
* @returns {Promise<String|GPGME_Error>}
* @async
*/
@ -229,12 +231,12 @@ export class GPGME_Key {
};
/**
* Find out if the Key includes a secret part. Note that this is a rather
* nonperformant operation, as it needs to query gnupg twice. If you want
* this inforrmation about more than a few Keys, it may be advisable to run
* {@link Keyring.getKeys} instead.
* @returns {Promise<Boolean|GPGME_Error>} True if a secret/private Key is
* available in the gnupg Keyring
* Find out if the Key includes a secret part. Note that this is a
* rather nonperformant operation, as it needs to query gnupg twice.
* If you want this inforrmation about more than a few Keys, it may be
* advisable to run {@link Keyring.getKeys} instead.
* @returns {Promise<Boolean|GPGME_Error>} True if a secret/private Key
* is available in the gnupg Keyring
* @async
*/
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
* secret key is not supported by the native backend.
* Deletes the (public) Key from the GPG Keyring. Note that a deletion
* of a secret key is not supported by the native backend.
* @returns {Promise<Boolean|GPGME_Error>} Success if key was deleted,
* rejects with a GPG error otherwise.
*/
@ -342,8 +344,6 @@ class GPGME_Subkey {
setProperty(keys[i], data[keys[i]]);
}
/**
* Fetches any information about this subkey
* @param {String} property Information to request
@ -354,8 +354,7 @@ class GPGME_Subkey {
return (_data[property]);
}
};
}
}
}
/**
@ -407,9 +406,9 @@ class GPGME_UserId {
return (_data[property]);
}
};
}
}
}
/**
* Validation definition for userIds. Each valid userId property is represented
* 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.
*
* @param {String | Array<String>} pattern (optional) A pattern to search
* for in userIds or KeyIds.
* @param {Boolean} prepare_sync (optional) if set to true, the 'hasSecret'
* and 'armored' properties will be fetched for the Keys as well. These
* require additional calls to gnupg, resulting in a performance hungry
* operation. Calling them here enables direct, synchronous use of these
* properties for all keys, without having to resort to a refresh() first.
* @param {Boolean} search (optional) retrieve Keys from external servers
* with the method(s) defined in gnupg (e.g. WKD/HKP lookup)
* @param {String | Array<String>} pattern (optional) A pattern to
* search for in userIds or KeyIds.
* @param {Boolean} prepare_sync (optional) if set to true, the
* 'hasSecret' and 'armored' properties will be fetched for the Keys as
* well. These require additional calls to gnupg, resulting in a
* performance hungry operation. Calling them here enables direct,
* synchronous use of these properties for all keys, without having to
* resort to a refresh() first.
* @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>}
* @static
* @async
@ -82,12 +83,15 @@ export class GPGME_Keyring {
if (prepare_sync === true){
result.keys[i].hasSecret = false;
if (answer && answer.keys) {
for (let j=0; j < answer.keys.length; j++ ){
if (result.keys[i].fingerprint ===
answer.keys[j].fingerprint
for (let j=0;
j < answer.keys.length; j++ ){
const a = answer.keys[j];
const b = result.keys[i];
if (
a.fingerprint === b.fingerprint
) {
if (answer.keys[j].secret === true){
result.keys[i].hasSecret = true;
if (a.secret === true){
a.hasSecret = true;
}
break;
}
@ -109,20 +113,21 @@ 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.
* @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).
* @param {String|Array<String>} pattern (optional) The Pattern to search
* for
* Fetches the armored public Key blocks for all Keys matching the
* pattern (if no pattern is given, fetches all keys known to gnupg).
* @param {String|Array<String>} pattern (optional) The Pattern to
* search for
* @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
@ -157,8 +162,8 @@ export class GPGME_Keyring {
/**
* Returns the Key used by default in gnupg.
* (a.k.a. 'primary Key or 'main key').
* It looks up the gpg configuration if set, or the first key that contains
* a secret key.
* It looks up the gpg configuration if set, or the first key that
* contains a secret key.
*
* @returns {Promise<GPGME_Key|GPGME_Error>}
* @async
@ -175,7 +180,8 @@ export class GPGME_Keyring {
&& response.value.hasOwnProperty('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){
resolve(keys[0]);
} else {
@ -224,7 +230,8 @@ export class GPGME_Keyring {
* @property {GPGME_Key} key The resulting key
* @property {String} status:
* '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,
* Key.changes is available.
* @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
* not succeed on private Key blocks.
* @param {String} armored Armored Key block of the Key(s) to be imported
* into gnupg
* Import an armored Key block into gnupg. Note that this currently
* will not succeed on private Key blocks.
* @param {String} armored Armored Key block of the Key(s) to be
* imported into gnupg
* @param {Boolean} prepare_sync prepare the keys for synched use
* (see {@link getKeys}).
* @returns {Promise<importResult>} A summary and Keys considered.
@ -287,7 +294,8 @@ export class GPGME_Keyring {
for (let i=0; i < result.length; i++) {
resultset.push({
key: result[i],
changes: infos[result[i].fingerprint].changes,
changes:
infos[result[i].fingerprint].changes,
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
* representing that Key. Please note that due to security concerns, secret
* Keys can not be deleted or exported from inside gpgme.js.
* representing that Key. Please note that due to security concerns,
* 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} algo (optional) algorithm (and optionally key size) to
* be used. See {@link supportedKeyAlgos} below for supported values.
* @param {Date} expires (optional) Expiration date. If not set, expiration
* will be set to 'never'
* @param {String} algo (optional) algorithm (and optionally key size)
* to be used. See {@link supportedKeyAlgos} below for supported
* values.
* @param {Date} expires (optional) Expiration date. If not set,
* expiration will be set to 'never'
*
* @return {Promise<Key|GPGME_Error>}
* @async
@ -374,7 +383,7 @@ export class GPGME_Keyring {
}
msg.post().then(function(response){
me.getKeys(response.fingerprint, true).then(
// TODO make prepare_sync (second parameter) optional here.
// TODO prepare_sync?
function(result){
resolve(result);
}, 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,
* most browsers will only accept answers up to 1 MB of size. Everything
* above that threshold will not pass through nativeMessaging; answers that
* are larger need to be sent in parts. The lower limit is set to 10 KB.
* Messages smaller than the threshold will not encounter problems, larger
* messages will be received in chunks.
* If the value is not explicitly specified, 1023 KB is used.
* most browsers will only accept answers up to 1 MB of size.
* Everything above that threshold will not pass through
* nativeMessaging; answers that are larger need to be sent in parts.
* The lower limit is set to 10 KB. Messages smaller than the threshold
* will not encounter problems, larger messages will be received in
* chunks. If the value is not explicitly specified, 1023 KB is used.
*/
this.setChunksize = function (value){
if (
@ -216,7 +216,7 @@ export class GPGME_Message {
}
});
};
}
}
/**
* Returns the prepared message with parameters and completeness checked
@ -231,11 +231,10 @@ export class GPGME_Message {
return null;
}
}
get operation(){
get operation(){
return this.getOperation();
}
get chunksize(){
}
get chunksize(){
return this.getChunksize();
}
}
}

View File

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

View File

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