From 9e85f75519dbb65c391bee08ee20b9e5a8284733 Mon Sep 17 00:00:00 2001 From: Daniel Huigens <d.huigens@protonmail.com> Date: Sun, 28 Feb 2021 00:48:21 +0100 Subject: [PATCH] Don't mark async function as returning a Promise explicitly It seems redundant. --- src/cleartext.js | 8 +++--- src/crypto/crypto.js | 2 +- src/crypto/eax.js | 6 +++-- src/crypto/hash/index.js | 3 ++- src/crypto/ocb.js | 8 +++--- src/crypto/pkcs1.js | 2 +- src/crypto/public_key/dsa.js | 2 +- src/crypto/public_key/elgamal.js | 2 +- src/crypto/public_key/elliptic/curves.js | 2 +- src/crypto/public_key/elliptic/ecdh.js | 22 ++++++++-------- src/crypto/public_key/elliptic/ecdsa.js | 2 +- src/crypto/public_key/elliptic/eddsa.js | 2 +- src/crypto/public_key/rsa.js | 2 +- src/encoding/armor.js | 2 +- src/hkp.js | 2 +- src/key/factory.js | 8 +++--- src/key/helper.js | 13 +++++----- src/key/key.js | 26 +++++++++---------- src/key/subkey.js | 8 +++--- src/key/user.js | 10 +++---- src/message.js | 20 +++++++------- src/openpgp.js | 24 ++++++++--------- .../public_key_encrypted_session_key.js | 4 +-- .../sym_encrypted_integrity_protected_data.js | 4 +-- 24 files changed, 95 insertions(+), 89 deletions(-) diff --git a/src/cleartext.js b/src/cleartext.js index 0ed825eb..b51e0a36 100644 --- a/src/cleartext.js +++ b/src/cleartext.js @@ -62,7 +62,7 @@ export class CleartextMessage { * @param {Date} [date] - The creation time of the signature that should be created * @param {Array} [userIds] - User IDs to sign with, e.g. [{ name:'Steve Sender', email:'steve@openpgp.org' }] * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<CleartextMessage>} New cleartext message with signed content. + * @returns {CleartextMessage} New cleartext message with signed content. * @async */ async sign(privateKeys, signature = null, signingKeyIds = [], date = new Date(), userIds = [], config = defaultConfig) { @@ -77,7 +77,7 @@ export class CleartextMessage { * @param {Date} [date] - The creation time of the signature that should be created * @param {Array} [userIds] - User IDs to sign with, e.g. [{ name:'Steve Sender', email:'steve@openpgp.org' }] * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Signature>} New detached signature of message content. + * @returns {Signature} New detached signature of message content. * @async */ async signDetached(privateKeys, signature = null, signingKeyIds = [], date = new Date(), userIds = [], config = defaultConfig) { @@ -92,7 +92,7 @@ export class CleartextMessage { * @param {Array<Key>} keys - Array of keys to verify signatures * @param {Date} [date] - Verify the signature against the given date, i.e. check signature creation time < date < expiration time * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Array<{keyid: module:type/keyid~Keyid, valid: Boolean}>>} List of signer's keyid and validity of signature. + * @returns {Array<{keyid: module:type/keyid~Keyid, valid: Boolean}>} List of signer's keyid and validity of signature. * @async */ verify(keys, date = new Date(), config = defaultConfig) { @@ -104,7 +104,7 @@ export class CleartextMessage { * @param {Array<Key>} keys - Array of keys to verify signatures * @param {Date} [date] - Verify the signature against the given date, i.e. check signature creation time < date < expiration time * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Array<{keyid: module:type/keyid~Keyid, valid: Boolean}>>} List of signer's keyid and validity of signature. + * @returns {Array<{keyid: module:type/keyid~Keyid, valid: Boolean}>} List of signer's keyid and validity of signature. * @async */ verifyDetached(signature, keys, date = new Date(), config = defaultConfig) { diff --git a/src/crypto/crypto.js b/src/crypto/crypto.js index 2fbeb787..cd75134c 100644 --- a/src/crypto/crypto.js +++ b/src/crypto/crypto.js @@ -298,7 +298,7 @@ export function generateParams(algo, bits, oid) { * @param {module:enums.publicKey} algo - The public key algorithm * @param {Object} publicParams - Algorithm-specific public key parameters * @param {Object} privateParams - Algorithm-specific private key parameters - * @returns {Promise<Boolean>} Whether the parameters are valid. + * @returns {Boolean} Whether the parameters are valid. * @async */ export async function validateParams(algo, publicParams, privateParams) { diff --git a/src/crypto/eax.js b/src/crypto/eax.js index 7d1da2e7..d4d0198c 100644 --- a/src/crypto/eax.js +++ b/src/crypto/eax.js @@ -99,7 +99,8 @@ async function EAX(cipher, key) { * @param {Uint8Array} plaintext - The cleartext input to be encrypted * @param {Uint8Array} nonce - The nonce (16 bytes) * @param {Uint8Array} adata - Associated data to sign - * @returns {Promise<Uint8Array>} The ciphertext output. + * @returns {Uint8Array} The ciphertext output. + * @async */ encrypt: async function(plaintext, nonce, adata) { const [ @@ -123,7 +124,8 @@ async function EAX(cipher, key) { * @param {Uint8Array} ciphertext - The ciphertext input to be decrypted * @param {Uint8Array} nonce - The nonce (16 bytes) * @param {Uint8Array} adata - Associated data to verify - * @returns {Promise<Uint8Array>} The plaintext output. + * @returns {Uint8Array} The plaintext output. + * @async */ decrypt: async function(ciphertext, nonce, adata) { if (ciphertext.length < tagLength) throw new Error('Invalid EAX ciphertext'); diff --git a/src/crypto/hash/index.js b/src/crypto/hash/index.js index bebcbbc7..416e07da 100644 --- a/src/crypto/hash/index.js +++ b/src/crypto/hash/index.js @@ -101,7 +101,8 @@ export default { * Create a hash on the specified data using the specified algorithm * @param {module:enums.hash} algo - Hash algorithm type (see {@link https://tools.ietf.org/html/rfc4880#section-9.4|RFC 4880 9.4}) * @param {Uint8Array} data - Data to be hashed - * @returns {Promise<Uint8Array>} Hash value. + * @returns {Uint8Array} Hash value. + * @async */ digest: function(algo, data) { switch (algo) { diff --git a/src/crypto/ocb.js b/src/crypto/ocb.js index 73069506..302cf447 100644 --- a/src/crypto/ocb.js +++ b/src/crypto/ocb.js @@ -136,7 +136,7 @@ async function OCB(cipher, key) { * @param {Uint8Array} text - The cleartext or ciphertext (without tag) input * @param {Uint8Array} nonce - The nonce (15 bytes) * @param {Uint8Array} adata - Associated data to sign - * @returns {Promise<Uint8Array>} The ciphertext or plaintext output, with tag appended in both cases. + * @returns {Uint8Array} The ciphertext or plaintext output, with tag appended in both cases. */ function crypt(fn, text, nonce, adata) { // @@ -223,7 +223,8 @@ async function OCB(cipher, key) { * @param {Uint8Array} plaintext - The cleartext input to be encrypted * @param {Uint8Array} nonce - The nonce (15 bytes) * @param {Uint8Array} adata - Associated data to sign - * @returns {Promise<Uint8Array>} The ciphertext output. + * @returns {Uint8Array} The ciphertext output. + * @async */ encrypt: async function(plaintext, nonce, adata) { return crypt(encipher, plaintext, nonce, adata); @@ -234,7 +235,8 @@ async function OCB(cipher, key) { * @param {Uint8Array} ciphertext - The ciphertext input to be decrypted * @param {Uint8Array} nonce - The nonce (15 bytes) * @param {Uint8Array} adata - Associated data to sign - * @returns {Promise<Uint8Array>} The ciphertext output. + * @returns {Uint8Array} The ciphertext output. + * @async */ decrypt: async function(ciphertext, nonce, adata) { if (ciphertext.length < tagLength) throw new Error('Invalid OCB ciphertext'); diff --git a/src/crypto/pkcs1.js b/src/crypto/pkcs1.js index c00402b2..d7442c55 100644 --- a/src/crypto/pkcs1.js +++ b/src/crypto/pkcs1.js @@ -71,7 +71,7 @@ async function getPkcs1Padding(length) { * @see {@link https://tools.ietf.org/html/rfc4880#section-13.1.1|RFC 4880 13.1.1} * @param {Uint8Array} message - Message to be encoded * @param {Integer} keyLength - The length in octets of the key modulus - * @returns {Promise<Uint8Array>} EME-PKCS1 padded message. + * @returns {Uint8Array} EME-PKCS1 padded message. * @async */ export async function emeEncode(message, keyLength) { diff --git a/src/crypto/public_key/dsa.js b/src/crypto/public_key/dsa.js index 39c60683..fef1178a 100644 --- a/src/crypto/public_key/dsa.js +++ b/src/crypto/public_key/dsa.js @@ -140,7 +140,7 @@ export async function verify(hash_algo, r, s, hashed, g, p, q, y) { * @param {Uint8Array} g - DSA sub-group generator * @param {Uint8Array} y - DSA public key * @param {Uint8Array} x - DSA private key - * @returns {Promise<Boolean>} Whether params are valid. + * @returns {Boolean} Whether params are valid. * @async */ export async function validateParams(p, q, g, y, x) { diff --git a/src/crypto/public_key/elgamal.js b/src/crypto/public_key/elgamal.js index 511bf463..87c12995 100644 --- a/src/crypto/public_key/elgamal.js +++ b/src/crypto/public_key/elgamal.js @@ -79,7 +79,7 @@ export async function decrypt(c1, c2, p, x) { * @param {Uint8Array} g - ElGamal group generator * @param {Uint8Array} y - ElGamal public key * @param {Uint8Array} x - ElGamal private exponent - * @returns {Promise<Boolean>} Whether params are valid. + * @returns {Boolean} Whether params are valid. * @async */ export async function validateParams(p, g, y, x) { diff --git a/src/crypto/public_key/elliptic/curves.js b/src/crypto/public_key/elliptic/curves.js index 3293cc10..479ba54b 100644 --- a/src/crypto/public_key/elliptic/curves.js +++ b/src/crypto/public_key/elliptic/curves.js @@ -231,7 +231,7 @@ function getPreferredHashAlgo(oid) { * @param {module:type/oid} oid - EC object identifier * @param {Uint8Array} Q - EC public point * @param {Uint8Array} d - EC secret scalar - * @returns {Promise<Boolean>} Whether params are valid. + * @returns {Boolean} Whether params are valid. * @async */ async function validateStandardParams(algo, oid, Q, d) { diff --git a/src/crypto/public_key/elliptic/ecdh.js b/src/crypto/public_key/elliptic/ecdh.js index db743caf..4a3c3443 100644 --- a/src/crypto/public_key/elliptic/ecdh.js +++ b/src/crypto/public_key/elliptic/ecdh.js @@ -41,7 +41,7 @@ const nodeCrypto = util.getNodeCrypto(); * @param {module:type/oid} oid - Elliptic curve object identifier * @param {Uint8Array} Q - ECDH public point * @param {Uint8Array} d - ECDH secret scalar - * @returns {Promise<Boolean>} Whether params are valid. + * @returns {Boolean} Whether params are valid. * @async */ export async function validateParams(oid, Q, d) { @@ -88,7 +88,7 @@ async function kdf(hash_algo, X, length, param, stripLeading = false, stripTrail * * @param {Curve} curve - Elliptic curve object * @param {Uint8Array} Q - Recipient public key - * @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}>} + * @returns {{publicKey: Uint8Array, sharedKey: Uint8Array}} * @async */ async function genPublicEphemeralKey(curve, Q) { @@ -123,7 +123,7 @@ async function genPublicEphemeralKey(curve, Q) { * @param {Uint8Array} data - Unpadded session key data * @param {Uint8Array} Q - Recipient public key * @param {Uint8Array} fingerprint - Recipient fingerprint - * @returns {Promise<{publicKey: Uint8Array, wrappedKey: Uint8Array}>} + * @returns {{publicKey: Uint8Array, wrappedKey: Uint8Array}} * @async */ export async function encrypt(oid, kdfParams, data, Q, fingerprint) { @@ -145,7 +145,7 @@ export async function encrypt(oid, kdfParams, data, Q, fingerprint) { * @param {Uint8Array} V - Public part of ephemeral key * @param {Uint8Array} Q - Recipient public key * @param {Uint8Array} d - Recipient private key - * @returns {Promise<{secretKey: Uint8Array, sharedKey: Uint8Array}>} + * @returns {{secretKey: Uint8Array, sharedKey: Uint8Array}} * @async */ async function genPrivateEphemeralKey(curve, V, Q, d) { @@ -185,7 +185,7 @@ async function genPrivateEphemeralKey(curve, V, Q, d) { * @param {Uint8Array} Q - Recipient public key * @param {Uint8Array} d - Recipient private key * @param {Uint8Array} fingerprint - Recipient fingerprint - * @returns {Promise<Uint8Array>} Value derived from session key. + * @returns {Uint8Array} Value derived from session key. * @async */ export async function decrypt(oid, kdfParams, V, C, Q, d, fingerprint) { @@ -213,7 +213,7 @@ export async function decrypt(oid, kdfParams, V, C, Q, d, fingerprint) { * @param {Uint8Array} V - Public part of ephemeral key * @param {Uint8Array} Q - Recipient public key * @param {Uint8Array} d - Recipient private key - * @returns {Promise<{secretKey: Uint8Array, sharedKey: Uint8Array}>} + * @returns {{secretKey: Uint8Array, sharedKey: Uint8Array}} * @async */ async function webPrivateEphemeralKey(curve, V, Q, d) { @@ -264,7 +264,7 @@ async function webPrivateEphemeralKey(curve, V, Q, d) { * * @param {Curve} curve - Elliptic curve object * @param {Uint8Array} Q - Recipient public key - * @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}>} + * @returns {{publicKey: Uint8Array, sharedKey: Uint8Array}} * @async */ async function webPublicEphemeralKey(curve, Q) { @@ -313,7 +313,7 @@ async function webPublicEphemeralKey(curve, Q) { * @param {Curve} curve - Elliptic curve object * @param {Uint8Array} V - Public part of ephemeral key * @param {Uint8Array} d - Recipient private key - * @returns {Promise<{secretKey: Uint8Array, sharedKey: Uint8Array}>} + * @returns {{secretKey: Uint8Array, sharedKey: Uint8Array}} * @async */ async function ellipticPrivateEphemeralKey(curve, V, d) { @@ -332,7 +332,7 @@ async function ellipticPrivateEphemeralKey(curve, V, d) { * * @param {Curve} curve - Elliptic curve object * @param {Uint8Array} Q - Recipient public key - * @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}>} + * @returns {{publicKey: Uint8Array, sharedKey: Uint8Array}} * @async */ async function ellipticPublicEphemeralKey(curve, Q) { @@ -353,7 +353,7 @@ async function ellipticPublicEphemeralKey(curve, Q) { * @param {Curve} curve - Elliptic curve object * @param {Uint8Array} V - Public part of ephemeral key * @param {Uint8Array} d - Recipient private key - * @returns {Promise<{secretKey: Uint8Array, sharedKey: Uint8Array}>} + * @returns {{secretKey: Uint8Array, sharedKey: Uint8Array}} * @async */ async function nodePrivateEphemeralKey(curve, V, d) { @@ -369,7 +369,7 @@ async function nodePrivateEphemeralKey(curve, V, d) { * * @param {Curve} curve - Elliptic curve object * @param {Uint8Array} Q - Recipient public key - * @returns {Promise<{publicKey: Uint8Array, sharedKey: Uint8Array}>} + * @returns {{publicKey: Uint8Array, sharedKey: Uint8Array}} * @async */ async function nodePublicEphemeralKey(curve, Q) { diff --git a/src/crypto/public_key/elliptic/ecdsa.js b/src/crypto/public_key/elliptic/ecdsa.js index f0d0efa3..cbe25b63 100644 --- a/src/crypto/public_key/elliptic/ecdsa.js +++ b/src/crypto/public_key/elliptic/ecdsa.js @@ -119,7 +119,7 @@ export async function verify(oid, hash_algo, signature, message, publicKey, hash * @param {module:type/oid} oid - Elliptic curve object identifier * @param {Uint8Array} Q - EcDSA public point * @param {Uint8Array} d - EcDSA secret scalar - * @returns {Promise<Boolean>} Whether params are valid. + * @returns {Boolean} Whether params are valid. * @async */ export async function validateParams(oid, Q, d) { diff --git a/src/crypto/public_key/elliptic/eddsa.js b/src/crypto/public_key/elliptic/eddsa.js index 97047bb6..9e7d98e4 100644 --- a/src/crypto/public_key/elliptic/eddsa.js +++ b/src/crypto/public_key/elliptic/eddsa.js @@ -70,7 +70,7 @@ export async function verify(oid, hash_algo, { r, s }, m, publicKey, hashed) { * @param {module:type/oid} oid - Elliptic curve object identifier * @param {Uint8Array} Q - EdDSA public point * @param {Uint8Array} k - EdDSA secret seed - * @returns {Promise<Boolean>} Whether params are valid. + * @returns {Boolean} Whether params are valid. * @async */ export async function validateParams(oid, Q, k) { diff --git a/src/crypto/public_key/rsa.js b/src/crypto/public_key/rsa.js index 69de677b..db46e79d 100644 --- a/src/crypto/public_key/rsa.js +++ b/src/crypto/public_key/rsa.js @@ -288,7 +288,7 @@ export async function generate(bits, e) { * @param {Uint8Array} p - RSA private prime p * @param {Uint8Array} q - RSA private prime q * @param {Uint8Array} u - RSA inverse of p w.r.t. q - * @returns {Promise<Boolean>} Whether params are valid. + * @returns {Boolean} Whether params are valid. * @async */ export async function validateParams(n, e, d, p, q, u) { diff --git a/src/encoding/armor.js b/src/encoding/armor.js index 97363d30..b51f3265 100644 --- a/src/encoding/armor.js +++ b/src/encoding/armor.js @@ -223,7 +223,7 @@ function splitChecksum(text) { * Dearmor an OpenPGP armored message; verify the checksum and return * the encoded bytes * @param {String} input - OpenPGP armored message - * @returns {Promise<Object>} An object with attribute "text" containing the message text, + * @returns {Object} An object with attribute "text" containing the message text, * an attribute "data" containing a stream of bytes and "type" for the ASCII armor type * @async * @static diff --git a/src/hkp.js b/src/hkp.js index 72baae1c..3b39b882 100644 --- a/src/hkp.js +++ b/src/hkp.js @@ -39,7 +39,7 @@ class HKP { * @param {String} options.keyId The long public key ID. * @param {String} options.query This can be any part of the key user ID such as name * or email address. - * @returns {Promise<String>} The ascii armored public key. + * @returns {String} The ascii armored public key. * @async */ lookup(options) { diff --git a/src/key/factory.js b/src/key/factory.js index e02adbfc..92e53f2a 100644 --- a/src/key/factory.js +++ b/src/key/factory.js @@ -36,7 +36,7 @@ import { unarmor } from '../encoding/armor'; * @param {Object} config - Full configuration * @param {Array<Object>} options.subkeys (optional) options for each subkey, default to main key options. e.g. [{sign: true, passphrase: '123'}] * sign parameter defaults to false, and indicates whether the subkey should sign rather than encrypt - * @returns {Promise<Key>} + * @returns {Key} * @async * @static * @private @@ -60,7 +60,7 @@ export async function generate(options, config) { * @param {Array<Object>} options.subkeys (optional) options for each subkey, default to main key options. e.g. [{sign: true, passphrase: '123'}] * @param {Object} config - Full configuration * - * @returns {Promise<Key>} + * @returns {Key} * @async * @static * @private @@ -248,7 +248,7 @@ async function wrapKeyObject(secretKeyPacket, secretSubkeyPackets, options, conf * @param {String | ReadableStream<String>} [options.armoredKey] - Armored key to be parsed * @param {Uint8Array | ReadableStream<Uint8Array>} [options.binaryKey] - Binary key to be parsed * @param {Object} [options.config] - Custom configuration settings to overwrite those in [config]{@link module:config} - * @returns {Promise<Key>} Key object. + * @returns {Key} Key object. * @async * @static */ @@ -278,7 +278,7 @@ export async function readKey({ armoredKey, binaryKey, config }) { * @param {String | ReadableStream<String>} [options.armoredKeys] - Armored keys to be parsed * @param {Uint8Array | ReadableStream<Uint8Array>} [options.binaryKeys] - Binary keys to be parsed * @param {Object} [options.config] - Custom configuration settings to overwrite those in [config]{@link module:config} - * @returns {Promise<Array<Key>>} Key objects. + * @returns {Array<Key>} Key objects. * @async * @static */ diff --git a/src/key/helper.js b/src/key/helper.js index a786fc6f..c307b8db 100644 --- a/src/key/helper.js +++ b/src/key/helper.js @@ -49,7 +49,7 @@ export async function generateSecretKey(options, config) { * @param {Array<SignaturePacket>} signatures - List of signatures * @param {Date} date - Use the given date instead of the current time * @param {Object} config - full configuration - * @returns {Promise<SignaturePacket>} The latest valid signature. + * @returns {SignaturePacket} The latest valid signature. * @async */ export async function getLatestValidSignature(signatures, primaryKey, signatureType, dataToVerify, date = new Date(), config) { @@ -128,7 +128,7 @@ export async function createBindingSignature(subkey, primaryKey, options, config * @param {Date} [date] - Use the given date for verification instead of the current time * @param {Object} [userId] - User ID * @param {Object} config - full configuration - * @returns {Promise<String>} + * @returns {String} * @async */ export async function getPreferredHashAlgo(key, keyPacket, date = new Date(), userId = {}, config) { @@ -165,7 +165,7 @@ export async function getPreferredHashAlgo(key, keyPacket, date = new Date(), us * @param {Date} [date] - Use the given date for verification instead of the current time * @param {Array} [userIds] - User IDs * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<module:enums.symmetric>} Preferred symmetric algorithm. + * @returns {module:enums.symmetric} Preferred symmetric algorithm. * @async */ export async function getPreferredAlgo(type, keys, date = new Date(), userIds = [], config = defaultConfig) { @@ -209,7 +209,8 @@ export async function getPreferredAlgo(type, keys, date = new Date(), userIds = * @param {Object} [detached] - Whether to create a detached signature packet * @param {Boolean} [streaming] - Whether to process data as a stream * @param {Object} config - full configuration - * @returns {Promise<SignaturePacket>} Signature packet. + * @returns {SignaturePacket} Signature packet. + * @async */ export async function createSignaturePacket(dataToSign, privateKey, signingKeyPacket, signatureProperties, date, userId, detached = false, streaming = false, config) { if (signingKeyPacket.isDummy()) { @@ -264,7 +265,7 @@ export async function mergeSignatures(source, dest, attr, checkFn) { * SecretKeyPacket} key, optional The key packet to check the signature * @param {Date} date - Use the given date instead of the current time * @param {Object} config - Full configuration - * @returns {Promise<Boolean>} True if the signature revokes the data. + * @returns {Boolean} True if the signature revokes the data. * @async */ export async function isDataRevoked(primaryKey, signatureType, dataToVerify, revocations, signature, key, date = new Date(), config) { @@ -316,7 +317,7 @@ export function getExpirationTime(keyPacket, signature) { * @param {Date} [date] - Use the given date for verification instead of the current time * @param {Array} [userIds] - User IDs * @param {Object} config - full configuration - * @returns {Promise<Boolean>} + * @returns {Boolean} * @async */ export async function isAeadSupported(keys, date = new Date(), userIds = [], config = defaultConfig) { diff --git a/src/key/key.js b/src/key/key.js index b5bdfef9..369de903 100644 --- a/src/key/key.js +++ b/src/key/key.js @@ -156,7 +156,7 @@ class Key { /** * Clones the key object - * @returns {Promise<Key>} Shallow clone of the key. + * @returns {Key} Shallow clone of the key. * @async */ async clone() { @@ -275,7 +275,7 @@ class Key { * @param {Date} [date] - Use the given date for verification instead of the current time * @param {Object} userId, optional user ID * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Key|SubKey|null>} Key or null if no signing key has been found. + * @returns {Key|SubKey|null} Key or null if no signing key has been found. * @async */ async getSigningKey(keyId = null, date = new Date(), userId = {}, config = defaultConfig) { @@ -316,7 +316,7 @@ class Key { * @param {Date} date, optional * @param {String} userId, optional * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Key|SubKey|null>} Key or null if no encryption key has been found. + * @returns {Key|SubKey|null} Key or null if no encryption key has been found. * @async */ async getEncryptionKey(keyId, date = new Date(), userId = {}, config = defaultConfig) { @@ -355,7 +355,7 @@ class Key { * @param {Date} date, optional * @param {String} userId, optional * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Array<Key|SubKey>>} Array of decryption keys. + * @returns {Array<Key|SubKey>} Array of decryption keys. * @async */ async getDecryptionKeys(keyId, date = new Date(), userId = {}, config = defaultConfig) { @@ -521,7 +521,7 @@ class Key { * SecretKeyPacket} key, optional The key to verify the signature * @param {Date} date - Use the given date instead of the current time * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Boolean>} True if the certificate is revoked. + * @returns {Boolean} True if the certificate is revoked. * @async */ async isRevoked(signature, key, date = new Date(), config = defaultConfig) { @@ -562,7 +562,7 @@ class Key { * @param {module:type/keyid~Keyid} keyId, optional * @param {Object} userId, optional user ID * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Date | Infinity | null>} + * @returns {Date | Infinity | null} * @async */ async getExpirationTime(capabilities, keyId, userId, config = defaultConfig) { @@ -653,7 +653,7 @@ class Key { * the destination key is transformed to a private key. * @param {Key} key - Source key to merge * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<undefined>} + * @returns {undefined} * @async */ async update(key, config = defaultConfig) { @@ -718,7 +718,7 @@ class Key { * @param {String} reasonForRevocation.string optional, string explaining the reason for revocation * @param {Date} date - optional, override the creationtime of the revocation signature * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Key>} New key with revocation signature. + * @returns {Key} New key with revocation signature. * @async */ async revoke( @@ -747,7 +747,7 @@ class Key { * (To get a revocation certificate for an unrevoked key, call revoke() first.) * @param {Date} date - Use the given date instead of the current time * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<String>} Armored revocation certificate. + * @returns {String} Armored revocation certificate. * @async */ async getRevocationCertificate(date = new Date(), config = defaultConfig) { @@ -764,7 +764,7 @@ class Key { * if it is a valid revocation signature. * @param {String} revocationCertificate - armored revocation certificate * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Key>} New revoked key. + * @returns {Key} New revoked key. * @async */ async applyRevocationCertificate(revocationCertificate, config = defaultConfig) { @@ -797,7 +797,7 @@ class Key { * @param {Date} [date] - Use the given date for verification instead of the current time * @param {Object} [userId] - User ID to get instead of the primary user, if it exists * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Key>} New public key with new certificate signature. + * @returns {Key} New public key with new certificate signature. * @async */ async signPrimaryUser(privateKeys, date, userId, config = defaultConfig) { @@ -812,7 +812,7 @@ class Key { * Signs all users of key * @param {Array<Key>} privateKeys - decrypted private keys for signing * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Key>} New public key with new certificate signature. + * @returns {Key} New public key with new certificate signature. * @async */ async signAllUsers(privateKeys, config = defaultConfig) { @@ -882,7 +882,7 @@ class Key { * @param {Date} options.date (optional) Override the creation date of the key and the key signatures * @param {Boolean} options.sign (optional) Indicates whether the subkey should sign rather than encrypt. Defaults to false * @param {Object} options.config (optional) custom configuration settings to overwrite those in [config]{@link module:config} - * @returns {Promise<Key>} + * @returns {Key} * @async */ async addSubkey(options = {}) { diff --git a/src/key/subkey.js b/src/key/subkey.js index 6ca15df9..720073f7 100644 --- a/src/key/subkey.js +++ b/src/key/subkey.js @@ -50,7 +50,7 @@ class SubKey { * SecretKeyPacket} key, optional The key to verify the signature * @param {Date} date - Use the given date instead of the current time * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Boolean>} True if the binding signature is revoked. + * @returns {Boolean} True if the binding signature is revoked. * @async */ async isRevoked(primaryKey, signature, key, date = new Date(), config = defaultConfig) { @@ -69,7 +69,7 @@ class SubKey { * PublicKeyPacket} primaryKey The primary key packet * @param {Date} date - Use the given date instead of the current time * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<SignaturePacket>} + * @returns {SignaturePacket} * @throws {Error} if the subkey is invalid. * @async */ @@ -95,7 +95,7 @@ class SubKey { * PublicKeyPacket} primaryKey The primary key packet * @param {Date} date - Use the given date instead of the current time * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Date | Infinity | null>} + * @returns {Date | Infinity | null} * @async */ async getExpirationTime(primaryKey, date = new Date(), config = defaultConfig) { @@ -162,7 +162,7 @@ class SubKey { * @param {String} reasonForRevocation.string optional, string explaining the reason for revocation * @param {Date} date - optional, override the creationtime of the revocation signature * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<SubKey>} New subkey with revocation signature. + * @returns {SubKey} New subkey with revocation signature. * @async */ async revoke( diff --git a/src/key/user.js b/src/key/user.js index 15b8ffad..b422557e 100644 --- a/src/key/user.js +++ b/src/key/user.js @@ -42,7 +42,7 @@ class User { * PublicKeyPacket} primaryKey The primary key packet * @param {Array<Key>} privateKeys - Decrypted private keys for signing * @param {Object} config - Full configuration - * @returns {Promise<Key>} New user with new certificate signatures. + * @returns {Key} New user with new certificate signatures. * @async */ async sign(primaryKey, privateKeys, config) { @@ -81,7 +81,7 @@ class User { * SecretKeyPacket} key, optional The key to verify the signature * @param {Date} date - Use the given date instead of the current time * @param {Object} config - Full configuration - * @returns {Promise<Boolean>} True if the certificate is revoked. + * @returns {Boolean} True if the certificate is revoked. * @async */ async isRevoked(primaryKey, certificate, key, date = new Date(), config) { @@ -102,7 +102,7 @@ class User { * @param {Array<Key>} keys - Array of keys to verify certificate signatures * @param {Date} date - Use the given date instead of the current time * @param {Object} config - Full configuration - * @returns {Promise<true|null>} Status of the certificate. + * @returns {true|null} Status of the certificate. * @async */ async verifyCertificate(primaryKey, certificate, keys, date = new Date(), config) { @@ -163,7 +163,7 @@ class User { * PublicKeyPacket} primaryKey The primary key packet * @param {Date} date - Use the given date instead of the current time * @param {Object} config - Full configuration - * @returns {Promise<true>} Status of user. + * @returns {true} Status of user. * @throws {Error} if there are no valid self signatures. * @async */ @@ -207,7 +207,7 @@ class User { * @param {SecretKeyPacket| * SecretSubkeyPacket} primaryKey primary key used for validation * @param {Object} config - Full configuration - * @returns {Promise<undefined>} + * @returns {undefined} * @async */ async update(user, primaryKey, config) { diff --git a/src/message.js b/src/message.js index b9995c43..29eb59d0 100644 --- a/src/message.js +++ b/src/message.js @@ -93,7 +93,7 @@ export class Message { * @param {Array<Object>} [sessionKeys] - Session keys in the form: { data:Uint8Array, algorithm:String, [aeadAlgorithm:String] } * @param {Boolean} [streaming] - Whether to process data as a stream * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Message>} New message with decrypted content. + * @returns {Message} New message with decrypted content. * @async */ async decrypt(privateKeys, passwords, sessionKeys, streaming, config = defaultConfig) { @@ -279,7 +279,7 @@ export class Message { * @param {Date} [date] - Date to select algorithm preferences at * @param {Array<Object>} [userIds] - User IDs to select algorithm preferences for * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<{ data: Uint8Array, algorithm: String }>} Object with session key data and algorithm. + * @returns {{ data: Uint8Array, algorithm: String }} Object with session key data and algorithm. * @async */ static async generateSessionKey(keys = [], date = new Date(), userIds = [], config = defaultConfig) { @@ -302,7 +302,7 @@ export class Message { * @param {Array<Object>} [userIds] - User IDs to encrypt for, e.g. [{ name:'Robert Receiver', email:'robert@openpgp.org' }] * @param {Boolean} [streaming] - Whether to process data as a stream * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Message>} New message with encrypted content. + * @returns {Message} New message with encrypted content. * @async */ async encrypt(keys, passwords, sessionKey, wildcard = false, encryptionKeyIds = [], date = new Date(), userIds = [], streaming, config = defaultConfig) { @@ -352,7 +352,7 @@ export class Message { * @param {Date} [date] - Override the date * @param {Array} [userIds] - User IDs to encrypt for, e.g. [{ name:'Robert Receiver', email:'robert@openpgp.org' }] * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Message>} New message with encrypted content. + * @returns {Message} New message with encrypted content. * @async */ static async encryptSessionKey(sessionKey, algorithm, aeadAlgorithm, publicKeys, passwords, wildcard = false, encryptionKeyIds = [], date = new Date(), userIds = [], config = defaultConfig) { @@ -420,7 +420,7 @@ export class Message { * @param {Array} [userIds] - User IDs to sign with, e.g. [{ name:'Steve Sender', email:'steve@openpgp.org' }] * @param {Boolean} [streaming] - Whether to process data as a stream * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Message>} New message with signed content. + * @returns {Message} New message with signed content. * @async */ async sign(privateKeys = [], signature = null, signingKeyIds = [], date = new Date(), userIds = [], streaming = false, config = defaultConfig) { @@ -506,7 +506,7 @@ export class Message { * @param {Array} [userIds] - User IDs to sign with, e.g. [{ name:'Steve Sender', email:'steve@openpgp.org' }] * @param {Boolean} [streaming] - Whether to process data as a stream * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Signature>} New detached signature of message content. + * @returns {Signature} New detached signature of message content. * @async */ async signDetached(privateKeys = [], signature = null, signingKeyIds = [], date = new Date(), userIds = [], streaming = false, config = defaultConfig) { @@ -523,7 +523,7 @@ export class Message { * @param {Date} [date] - Verify the signature against the given date, i.e. check signature creation time < date < expiration time * @param {Boolean} [streaming] - Whether to process data as a stream * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Array<({keyid: module:type/keyid~Keyid, valid: Boolean})>>} List of signer's keyid and validity of signature. + * @returns {Array<({keyid: module:type/keyid~Keyid, valid: Boolean})>} List of signer's keyid and validity of signature. * @async */ async verify(keys, date = new Date(), streaming, config = defaultConfig) { @@ -576,7 +576,7 @@ export class Message { * @param {Signature} signature * @param {Date} date - Verify the signature against the given date, i.e. check signature creation time < date < expiration time * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Array<({keyid: module:type/keyid~Keyid, valid: Boolean})>>} List of signer's keyid and validity of signature. + * @returns {Array<({keyid: module:type/keyid~Keyid, valid: Boolean})>} List of signer's keyid and validity of signature. * @async */ verifyDetached(signature, keys, date = new Date(), streaming, config = defaultConfig) { @@ -695,7 +695,7 @@ export class Message { * @param {Boolean} [detached] - Whether to create detached signature packets * @param {Boolean} [streaming] - Whether to process data as a stream * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<PacketList>} List of signature packets. + * @returns {PacketList} List of signature packets. * @async * @private */ @@ -815,7 +815,7 @@ export async function createVerificationObjects(signatureList, literalDataList, * @param {String | ReadableStream<String>} [options.armoredMessage] - Armored message to be parsed * @param {Uint8Array | ReadableStream<Uint8Array>} [options.binaryMessage] - Binary to be parsed * @param {Object} [options.config] - Custom configuration settings to overwrite those in [config]{@link module:config} - * @returns {Promise<Message>} New message object. + * @returns {Message} New message object. * @async * @static */ diff --git a/src/openpgp.js b/src/openpgp.js index 6cae1dcf..8b25a2c2 100644 --- a/src/openpgp.js +++ b/src/openpgp.js @@ -52,7 +52,7 @@ if (globalThis.ReadableStream) { * @param {Array<Object>} [options.subkeys=a single encryption subkey] - Options for each subkey, default to main key options. e.g. `[{sign: true, passphrase: '123'}]` * sign parameter defaults to false, and indicates whether the subkey should sign rather than encrypt * @param {Object} [options.config] - Custom configuration settings to overwrite those in [config]{@link module:config} - * @returns {Promise<Object>} The generated key object in the form: + * @returns {Object} The generated key object in the form: * { key:Key, privateKeyArmored:String, publicKeyArmored:String, revocationCertificate:String } * @async * @static @@ -88,7 +88,7 @@ export function generateKey({ userIds = [], passphrase = "", type = "ecc", rsaBi * @param {String} [options.passphrase=(not protected)] - The passphrase used to encrypt the generated private key * @param {Number} [options.keyExpirationTime=0 (never expires)] - Number of seconds from the key creation time after which the key expires * @param {Object} [options.config] - Custom configuration settings to overwrite those in [config]{@link module:config} - * @returns {Promise<Object>} The generated key object in the form: + * @returns {Object} The generated key object in the form: * { key:Key, privateKeyArmored:String, publicKeyArmored:String, revocationCertificate:String } * @async * @static @@ -123,7 +123,7 @@ export function reformatKey({ privateKey, userIds = [], passphrase = "", keyExpi * @param {module:enums.reasonForRevocation} [options.reasonForRevocation.flag=[noReason]{@link module:enums.reasonForRevocation}] - Flag indicating the reason for revocation * @param {String} [options.reasonForRevocation.string=""] - String explaining the reason for revocation * @param {Object} [options.config] - Custom configuration settings to overwrite those in [config]{@link module:config} - * @returns {Promise<Object>} The revoked key object in the form: + * @returns {Object} The revoked key object in the form: * `{ privateKey:Key, privateKeyArmored:String, publicKey:Key, publicKeyArmored:String }` * (if private key is passed) or `{ publicKey:Key, publicKeyArmored:String }` (otherwise) * @async @@ -161,7 +161,7 @@ export function revokeKey({ key, revocationCertificate, reasonForRevocation, con * @param {Key} options.privateKey - The private key to decrypt * @param {String|Array<String>} options.passphrase - The user's passphrase(s) * @param {Object} [options.config] - Custom configuration settings to overwrite those in [config]{@link module:config} - * @returns {Promise<Key>} The unlocked key object. + * @returns {Key} The unlocked key object. * @async */ export async function decryptKey({ privateKey, passphrase, config }) { @@ -190,7 +190,7 @@ export async function decryptKey({ privateKey, passphrase, config }) { * @param {Key} options.privateKey - The private key to encrypt * @param {String|Array<String>} options.passphrase - If multiple passphrases, they should be in the same order as the packets each should encrypt * @param {Object} [options.config] - Custom configuration settings to overwrite those in [config]{@link module:config} - * @returns {Promise<Key>} The locked key object. + * @returns {Key} The locked key object. * @async */ export async function encryptKey({ privateKey, passphrase, config }) { @@ -246,7 +246,7 @@ export async function encryptKey({ privateKey, passphrase, config }) { * @param {Array<Object>} [options.fromUserIds=primary user IDs] - Array of user IDs to sign with, one per key in `privateKeys`, e.g. `[{ name: 'Steve Sender', email: 'steve@openpgp.org' }]` * @param {Array<Object>} [options.toUserIds=primary user IDs] - Array of user IDs to encrypt for, one per key in `publicKeys`, e.g. `[{ name: 'Robert Receiver', email: 'robert@openpgp.org' }]` * @param {Object} [options.config] - Custom configuration settings to overwrite those in [config]{@link module:config} - * @returns {Promise<String|ReadableStream<String>|NodeStream<String>|Uint8Array|ReadableStream<Uint8Array>|NodeStream<Uint8Array>>} Encrypted message (string if `armor` was true, the default; Uint8Array if `armor` was false). + * @returns {String|ReadableStream<String>|NodeStream<String>|Uint8Array|ReadableStream<Uint8Array>|NodeStream<Uint8Array>} Encrypted message (string if `armor` was true, the default; Uint8Array if `armor` was false). * @async * @static */ @@ -285,7 +285,7 @@ export function encrypt({ message, publicKeys, privateKeys, passwords, sessionKe * @param {Signature} [options.signature] - Detached signature for verification * @param {Date} [options.date=current date] - Use the given date for verification instead of the current time * @param {Object} [options.config] - Custom configuration settings to overwrite those in [config]{@link module:config} - * @returns {Promise<Object>} Object containing decrypted and verified message in the form: + * @returns {Object} Object containing decrypted and verified message in the form: * * { * data: String|ReadableStream<String>|NodeStream, (if format was 'utf8', the default) @@ -342,7 +342,7 @@ export function decrypt({ message, privateKeys, passwords, sessionKeys, publicKe * @param {Date} [options.date=current date] - Override the creation date of the signature * @param {Array<Object>} [options.fromUserIds=primary user IDs] - Array of user IDs to sign with, one per key in `privateKeys`, e.g. `[{ name: 'Steve Sender', email: 'steve@openpgp.org' }]` * @param {Object} [options.config] - Custom configuration settings to overwrite those in [config]{@link module:config} - * @returns {Promise<String|ReadableStream<String>|NodeStream<String>|Uint8Array|ReadableStream<Uint8Array>|NodeStream<Uint8Array>>} Signed message (string if `armor` was true, the default; Uint8Array if `armor` was false). + * @returns {String|ReadableStream<String>|NodeStream<String>|Uint8Array|ReadableStream<Uint8Array>|NodeStream<Uint8Array>} Signed message (string if `armor` was true, the default; Uint8Array if `armor` was false). * @async * @static */ @@ -385,7 +385,7 @@ export function sign({ message, privateKeys, armor = true, streaming = message & * @param {Signature} [options.signature] - Detached signature for verification * @param {Date} [options.date=current date] - Use the given date for verification instead of the current time * @param {Object} [options.config] - Custom configuration settings to overwrite those in [config]{@link module:config} - * @returns {Promise<Object>} Object containing verified message in the form: + * @returns {Object} Object containing verified message in the form: * * { * data: String|ReadableStream<String>|NodeStream, (if `message` was a CleartextMessage) @@ -436,7 +436,7 @@ export function verify({ message, publicKeys, format = 'utf8', streaming = messa * @param {Date} [options.date=current date] - Date to select algorithm preferences at * @param {Array} [options.toUserIds=primary user IDs] - User IDs to select algorithm preferences for * @param {Object} [options.config] - Custom configuration settings to overwrite those in [config]{@link module:config} - * @returns {Promise<{ data: Uint8Array, algorithm: String }>} Object with session key data and algorithm. + * @returns {{ data: Uint8Array, algorithm: String }} Object with session key data and algorithm. * @async * @static */ @@ -466,7 +466,7 @@ export function generateSessionKey({ publicKeys, date = new Date(), toUserIds = * @param {Date} [options.date=current date] - Override the date * @param {Array} [options.toUserIds=primary user IDs] - Array of user IDs to encrypt for, one per key in `publicKeys`, e.g. `[{ name: 'Phil Zimmermann', email: 'phil@openpgp.org' }]` * @param {Object} [options.config] - Custom configuration settings to overwrite those in [config]{@link module:config} - * @returns {Promise<String|Uint8Array>} Encrypted session keys (string if `armor` was true, the default; Uint8Array if `armor` was false). + * @returns {String|Uint8Array} Encrypted session keys (string if `armor` was true, the default; Uint8Array if `armor` was false). * @async * @static */ @@ -490,7 +490,7 @@ export function encryptSessionKey({ data, algorithm, aeadAlgorithm, publicKeys, * @param {Key|Array<Key>} [options.privateKeys] - Private keys with decrypted secret key data * @param {String|Array<String>} [options.passwords] - Passwords to decrypt the session key * @param {Object} [options.config] - Custom configuration settings to overwrite those in [config]{@link module:config} - * @returns {Promise<Object|undefined>} Array of decrypted session key, algorithm pairs in the form: + * @returns {Object|undefined} Array of decrypted session key, algorithm pairs in the form: * { data:Uint8Array, algorithm:String } * or 'undefined' if no key packets found * @async diff --git a/src/packet/public_key_encrypted_session_key.js b/src/packet/public_key_encrypted_session_key.js index 805c74c2..92e5cffc 100644 --- a/src/packet/public_key_encrypted_session_key.js +++ b/src/packet/public_key_encrypted_session_key.js @@ -86,7 +86,7 @@ class PublicKeyEncryptedSessionKeyPacket { /** * Encrypt session key packet * @param {PublicKeyPacket} key - Public key - * @returns {Promise<Boolean>} + * @returns {Boolean} * @async */ async encrypt(key) { @@ -107,7 +107,7 @@ class PublicKeyEncryptedSessionKeyPacket { * * @param {SecretKeyPacket} key * Private key with secret params unlocked - * @returns {Promise<Boolean>} + * @returns {Boolean} * @async */ async decrypt(key) { diff --git a/src/packet/sym_encrypted_integrity_protected_data.js b/src/packet/sym_encrypted_integrity_protected_data.js index 2ad057cf..3e225683 100644 --- a/src/packet/sym_encrypted_integrity_protected_data.js +++ b/src/packet/sym_encrypted_integrity_protected_data.js @@ -80,7 +80,7 @@ class SymEncryptedIntegrityProtectedDataPacket { * @param {Uint8Array} key - The key of cipher blocksize length to be used * @param {Boolean} streaming - Whether to set this.encrypted to a stream * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Boolean>} + * @returns {Boolean} * @async */ async encrypt(sessionKeyAlgorithm, key, streaming, config = defaultConfig) { @@ -103,7 +103,7 @@ class SymEncryptedIntegrityProtectedDataPacket { * @param {Uint8Array} key - The key of cipher blocksize length to be used * @param {Boolean} streaming - Whether to read this.encrypted as a stream * @param {Object} [config] - Full configuration, defaults to openpgp.config - * @returns {Promise<Boolean>} + * @returns {Boolean} * @async */ async decrypt(sessionKeyAlgorithm, key, streaming, config = defaultConfig) {