From bbcdacef8d90e867e0e35c1ca1703b3278477133 Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Thu, 20 Sep 2018 17:02:50 +0200 Subject: [PATCH] Small documentation fixes --- src/key.js | 8 ++++---- src/openpgp.js | 2 +- test/serviceworker.js | 47 ------------------------------------------- 3 files changed, 5 insertions(+), 52 deletions(-) delete mode 100644 test/serviceworker.js diff --git a/src/key.js b/src/key.js index 982a5e28..1d30b871 100644 --- a/src/key.js +++ b/src/key.js @@ -483,11 +483,12 @@ Key.prototype.verifyPrimaryKey = async function(date=new Date(), userId={}) { /** * Returns the latest date when the key can be used for encrypting, signing, or both, depending on the `capabilities` paramater. * When `capabilities` is null, defaults to returning the expiry date of the primary key. + * Returns null if `capabilities` is passed and the key does not have the specified capabilities or is revoked or invalid. * Returns Infinity if the key doesn't expire. * @param {encrypt|sign|encrypt_sign} capabilities, optional * @param {module:type/keyid} keyId, optional * @param {Object} userId, optional user ID - * @returns {Promise} + * @returns {Promise} * @async */ Key.prototype.getExpirationTime = async function(capabilities, keyId, userId) { @@ -1116,10 +1117,11 @@ SubKey.prototype.verify = async function(primaryKey, date=new Date()) { /** * Returns the expiration time of the subkey or Infinity if key does not expire + * Returns null if the subkey is invalid. * @param {module:packet.SecretKey| * module:packet.PublicKey} primaryKey The primary key packet * @param {Date} date Use the given date instead of the current time - * @returns {Promise} + * @returns {Promise} * @async */ SubKey.prototype.getExpirationTime = async function(primaryKey, date=new Date()) { @@ -1199,8 +1201,6 @@ SubKey.prototype.revoke = async function(primaryKey, { return subKey; }; -/** - */ ['getKeyId', 'getFingerprint', 'getAlgorithmInfo', 'getCreationTime', 'isDecrypted'].forEach(name => { Key.prototype[name] = SubKey.prototype[name] = diff --git a/src/openpgp.js b/src/openpgp.js index 389416b3..8fb07ef8 100644 --- a/src/openpgp.js +++ b/src/openpgp.js @@ -344,7 +344,7 @@ export function encrypt({ message, publicKeys, privateKeys, passwords, sessionKe * @param {String|Array} passwords (optional) passwords to decrypt the message * @param {Object|Array} sessionKeys (optional) session keys in the form: { data:Uint8Array, algorithm:String } * @param {Key|Array} publicKeys (optional) array of public keys or single key, to verify signatures - * @param {String} format (optional) return data format either as 'utf8' or 'binary' + * @param {'utf8'|'binary'} format (optional) whether to return data as a string(Stream) or Uint8Array(Stream). If 'utf8' (the default), also normalize newlines. * @param {'web'|'node'|false} streaming (optional) whether to return data as a stream. Defaults to the type of stream `message` was created from, if any. * @param {Signature} signature (optional) detached signature for verification * @param {Date} date (optional) use the given date for verification instead of the current time diff --git a/test/serviceworker.js b/test/serviceworker.js deleted file mode 100644 index 157fd0f5..00000000 --- a/test/serviceworker.js +++ /dev/null @@ -1,47 +0,0 @@ - - - - -// addEventListener('fetch', event => { -// console.log(event); -// const url = new URL(event.request.url); -// console.log(url); -// if (url.pathname === '/test/somedata') { -// let plaintext = []; -// let i = 0; -// let canceled = false; -// const data = new ReadableStream({ -// /*start(_controller) { -// controller = _controller; -// },*/ -// async pull(controller) { -// await new Promise(resolve => setTimeout(resolve, 1000)); -// console.log(i); -// if (i++ < 10) { -// let randomBytes = new Uint8Array(1000); -// randomBytes.fill(i); -// controller.enqueue(randomBytes); -// plaintext.push(randomBytes); -// } else { -// controller.close(); -// } -// }, -// cancel() { -// console.log('canceled!'); -// } -// }); - - -// const response = new Response(data, { -// headers: { -// 'Content-Type': 'application/octet-stream; charset=utf-8', -// 'Content-Disposition': 'Content-Disposition: attachment; filename=data.bin;' -// } -// }); - -// event.respondWith(response); -// } - -// }); - - \ No newline at end of file