JSdoc types & ESLint fixes (#1132)
This commit is contained in:
parent
f6ee6e959e
commit
10aa1aa5cb
|
@ -156,7 +156,7 @@ export default {
|
||||||
|
|
||||||
/** Returns the types comprising the private key of an algorithm
|
/** Returns the types comprising the private key of an algorithm
|
||||||
* @param {module:enums.publicKey} algo The public key algorithm
|
* @param {module:enums.publicKey} algo The public key algorithm
|
||||||
* @returns {Array<String>} The array of types
|
* @returns {Array<Object>} The array of types
|
||||||
*/
|
*/
|
||||||
getPrivKeyParamTypes: function(algo) {
|
getPrivKeyParamTypes: function(algo) {
|
||||||
switch (algo) {
|
switch (algo) {
|
||||||
|
@ -190,7 +190,7 @@ export default {
|
||||||
|
|
||||||
/** Returns the types comprising the public key of an algorithm
|
/** Returns the types comprising the public key of an algorithm
|
||||||
* @param {module:enums.publicKey} algo The public key algorithm
|
* @param {module:enums.publicKey} algo The public key algorithm
|
||||||
* @returns {Array<String>} The array of types
|
* @returns {Array<Object>} The array of types
|
||||||
*/
|
*/
|
||||||
getPubKeyParamTypes: function(algo) {
|
getPubKeyParamTypes: function(algo) {
|
||||||
switch (algo) {
|
switch (algo) {
|
||||||
|
@ -233,7 +233,7 @@ export default {
|
||||||
|
|
||||||
/** Returns the types comprising the encrypted session key of an algorithm
|
/** Returns the types comprising the encrypted session key of an algorithm
|
||||||
* @param {module:enums.publicKey} algo The public key algorithm
|
* @param {module:enums.publicKey} algo The public key algorithm
|
||||||
* @returns {Array<String>} The array of types
|
* @returns {Array<Object>} The array of types
|
||||||
*/
|
*/
|
||||||
getEncSessionKeyParamTypes: function(algo) {
|
getEncSessionKeyParamTypes: function(algo) {
|
||||||
switch (algo) {
|
switch (algo) {
|
||||||
|
@ -303,7 +303,7 @@ export default {
|
||||||
* Validate algorithm-specific key parameters
|
* Validate algorithm-specific key parameters
|
||||||
* @param {module:enums.publicKey} algo The public key algorithm
|
* @param {module:enums.publicKey} algo The public key algorithm
|
||||||
* @param {Array} params The array of parameters
|
* @param {Array} params The array of parameters
|
||||||
* @returns {Promise<Boolean> whether the parameters are valid
|
* @returns {Promise<Boolean>} whether the parameters are valid
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
validateParams: async function(algo, params) {
|
validateParams: async function(algo, params) {
|
||||||
|
|
|
@ -103,7 +103,7 @@ async function verify(oid, hash_algo, signature, message, publicKey, hashed) {
|
||||||
return await webVerify(curve, hash_algo, signature, message, publicKey);
|
return await webVerify(curve, hash_algo, signature, message, publicKey);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// We do not fallback if the error is related to key integrity
|
// We do not fallback if the error is related to key integrity
|
||||||
// Unfortunaley Safari does not support p521 and throws a DataError when using it
|
// Unfortunately Safari does not support p521 and throws a DataError when using it
|
||||||
// So we need to always fallback for that curve
|
// So we need to always fallback for that curve
|
||||||
if (curve.name !== 'p521' && (err.name === 'DataError' || err.name === 'OperationError')) {
|
if (curve.name !== 'p521' && (err.name === 'DataError' || err.name === 'OperationError')) {
|
||||||
throw err;
|
throw err;
|
||||||
|
|
|
@ -48,9 +48,9 @@ import armor from '../encoding/armor';
|
||||||
* @param {String} options.passphrase The passphrase used to encrypt the resulting private key
|
* @param {String} options.passphrase The passphrase used to encrypt the resulting private key
|
||||||
* @param {Number} [options.keyExpirationTime=0]
|
* @param {Number} [options.keyExpirationTime=0]
|
||||||
* The number of seconds after the key creation time that the key expires
|
* The number of seconds after the key creation time that the key expires
|
||||||
* @param {String} curve (optional) elliptic curve for ECC keys
|
* @param {String} options.curve (optional) elliptic curve for ECC keys
|
||||||
* @param {Date} date Override the creation date of the key and the key signatures
|
* @param {Date} options.date Override the creation date of the key and the key signatures
|
||||||
* @param {Array<Object>} subkeys (optional) options for each subkey, default to main key options. e.g. [{sign: true, passphrase: '123'}]
|
* @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
|
* sign parameter defaults to false, and indicates whether the subkey should sign rather than encrypt
|
||||||
* @returns {Promise<module:key.Key>}
|
* @returns {Promise<module:key.Key>}
|
||||||
* @async
|
* @async
|
||||||
|
@ -76,8 +76,8 @@ export async function generate(options) {
|
||||||
* @param {String} options.passphrase The passphrase used to encrypt the resulting private key
|
* @param {String} options.passphrase The passphrase used to encrypt the resulting private key
|
||||||
* @param {Number} [options.keyExpirationTime=0]
|
* @param {Number} [options.keyExpirationTime=0]
|
||||||
* The number of seconds after the key creation time that the key expires
|
* The number of seconds after the key creation time that the key expires
|
||||||
* @param {Date} date Override the creation date of the key and the key signatures
|
* @param {Date} options.date Override the creation date of the key and the key signatures
|
||||||
* @param {Array<Object>} subkeys (optional) options for each subkey, default to main key options. e.g. [{sign: true, passphrase: '123'}]
|
* @param {Array<Object>} options.subkeys (optional) options for each subkey, default to main key options. e.g. [{sign: true, passphrase: '123'}]
|
||||||
*
|
*
|
||||||
* @returns {Promise<module:key.Key>}
|
* @returns {Promise<module:key.Key>}
|
||||||
* @async
|
* @async
|
||||||
|
|
|
@ -794,7 +794,7 @@ class Key {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signs primary user of key
|
* Signs primary user of key
|
||||||
* @param {Array<module:key.Key>} privateKey decrypted private keys for signing
|
* @param {Array<module:key.Key>} privateKeys decrypted private keys for signing
|
||||||
* @param {Date} date (optional) use the given date for verification instead of the current time
|
* @param {Date} date (optional) use the given date for verification instead of the current time
|
||||||
* @param {Object} userId (optional) user ID to get instead of the primary user, if it exists
|
* @param {Object} userId (optional) user ID to get instead of the primary user, if it exists
|
||||||
* @returns {Promise<module:key.Key>} new public key with new certificate signature
|
* @returns {Promise<module:key.Key>} new public key with new certificate signature
|
||||||
|
@ -875,9 +875,9 @@ class Key {
|
||||||
* @param {Integer} options.rsaBits number of bits for the key creation.
|
* @param {Integer} options.rsaBits number of bits for the key creation.
|
||||||
* @param {Number} [options.keyExpirationTime=0]
|
* @param {Number} [options.keyExpirationTime=0]
|
||||||
* The number of seconds after the key creation time that the key expires
|
* The number of seconds after the key creation time that the key expires
|
||||||
* @param {String} curve (optional) Elliptic curve for ECC keys
|
* @param {String} options.curve (optional) Elliptic curve for ECC keys
|
||||||
* @param {Date} date (optional) Override the creation date of the key and the key signatures
|
* @param {Date} options.date (optional) Override the creation date of the key and the key signatures
|
||||||
* @param {Boolean} sign (optional) Indicates whether the subkey should sign rather than encrypt. Defaults to false
|
* @param {Boolean} options.sign (optional) Indicates whether the subkey should sign rather than encrypt. Defaults to false
|
||||||
* @returns {Promise<module:key.Key>}
|
* @returns {Promise<module:key.Key>}
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -30,7 +30,7 @@ class SubKey {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms structured subkey data to packetlist
|
* Transforms structured subkey data to packetlist
|
||||||
* @returns {PacketListPacket}
|
* @returns {PacketList}
|
||||||
*/
|
*/
|
||||||
toPacketlist() {
|
toPacketlist() {
|
||||||
const packetlist = new PacketList();
|
const packetlist = new PacketList();
|
||||||
|
|
|
@ -24,8 +24,8 @@ import util from '../util';
|
||||||
*/
|
*/
|
||||||
class PacketList extends Array {
|
class PacketList extends Array {
|
||||||
/**
|
/**
|
||||||
* Reads a stream of binary data and interprents it as a list of packets.
|
* Reads a stream of binary data and interprets it as a list of packets.
|
||||||
* @param {Uint8Array | ReadableStream<Uint8Array>} A Uint8Array of bytes.
|
* @param {Uint8Array | ReadableStream<Uint8Array>} bytes A Uint8Array of bytes.
|
||||||
*/
|
*/
|
||||||
async read(bytes, allowedPackets, streaming) {
|
async read(bytes, allowedPackets, streaming) {
|
||||||
this.stream = stream.transformPair(bytes, async (readable, writable) => {
|
this.stream = stream.transformPair(bytes, async (readable, writable) => {
|
||||||
|
|
|
@ -161,7 +161,7 @@ class SecretKeyPacket extends PublicKeyPacket {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an OpenPGP key packet for the given key.
|
* Creates an OpenPGP key packet for the given key.
|
||||||
* @returns {String} A string of bytes containing the secret key OpenPGP packet
|
* @returns {Uint8Array} A string of bytes containing the secret key OpenPGP packet
|
||||||
*/
|
*/
|
||||||
write() {
|
write() {
|
||||||
const arr = [this.writePublicKey()];
|
const arr = [this.writePublicKey()];
|
||||||
|
|
|
@ -36,7 +36,7 @@ class Keyid {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parsing method for a key id
|
* Parsing method for a key id
|
||||||
* @param {Uint8Array} input Input to read the key id from
|
* @param {Uint8Array} bytes Input to read the key id from
|
||||||
*/
|
*/
|
||||||
read(bytes) {
|
read(bytes) {
|
||||||
this.bytes = util.uint8ArrayToStr(bytes.subarray(0, 8));
|
this.bytes = util.uint8ArrayToStr(bytes.subarray(0, 8));
|
||||||
|
|
|
@ -54,8 +54,8 @@ class MPI {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parsing function for a MPI ({@link https://tools.ietf.org/html/rfc4880#section-3.2|RFC 4880 3.2}).
|
* Parsing function for a MPI ({@link https://tools.ietf.org/html/rfc4880#section-3.2|RFC 4880 3.2}).
|
||||||
* @param {Uint8Array} input Payload of MPI data
|
* @param {Uint8Array|string} bytes Payload of MPI data
|
||||||
* @param {String} endian Endianness of the data; 'be' for big-endian or 'le' for little-endian
|
* @param {'be'|'le'} endian Endianness of the data; 'be' for big-endian or 'le' for little-endian
|
||||||
* @returns {Integer} Length of data read
|
* @returns {Integer} Length of data read
|
||||||
*/
|
*/
|
||||||
read(bytes, endian = 'be') {
|
read(bytes, endian = 'be') {
|
||||||
|
|
|
@ -59,7 +59,7 @@ class S2K {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parsing function for a string-to-key specifier ({@link https://tools.ietf.org/html/rfc4880#section-3.7|RFC 4880 3.7}).
|
* Parsing function for a string-to-key specifier ({@link https://tools.ietf.org/html/rfc4880#section-3.7|RFC 4880 3.7}).
|
||||||
* @param {String} input Payload of string-to-key specifier
|
* @param {String} bytes Payload of string-to-key specifier
|
||||||
* @returns {Integer} Actual length of the object
|
* @returns {Integer} Actual length of the object
|
||||||
*/
|
*/
|
||||||
read(bytes) {
|
read(bytes) {
|
||||||
|
|
|
@ -307,8 +307,8 @@ export default {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check Uint8Array equality
|
* Check Uint8Array equality
|
||||||
* @param {Uint8Array} first array
|
* @param {Uint8Array} array1 first array
|
||||||
* @param {Uint8Array} second array
|
* @param {Uint8Array} array2 second array
|
||||||
* @returns {Boolean} equality
|
* @returns {Boolean} equality
|
||||||
*/
|
*/
|
||||||
equalsUint8Array: function (array1, array2) {
|
equalsUint8Array: function (array1, array2) {
|
||||||
|
|
|
@ -242,7 +242,7 @@ EJ4QcD/oQ6x1M/8X/iKQCtxZP8RnlrbH7ExkNON5s5g=
|
||||||
expect(result.signatures[0].valid).to.be.true;
|
expect(result.signatures[0].valid).to.be.true;
|
||||||
});
|
});
|
||||||
it('Decrypt and verify message with leading zero in hash signed with old elliptic algorithm', async function () {
|
it('Decrypt and verify message with leading zero in hash signed with old elliptic algorithm', async function () {
|
||||||
//this test would not work with nodeCrypto, since message is signed with leading zero stripped from the hash
|
//this test would not work with nodeCrypto, since message is signed with leading zero stripped from the hash
|
||||||
const useNative = openpgp.config.useNative;
|
const useNative = openpgp.config.useNative;
|
||||||
openpgp.config.useNative = false;
|
openpgp.config.useNative = false;
|
||||||
const juliet = await load_priv_key('juliet');
|
const juliet = await load_priv_key('juliet');
|
||||||
|
|
|
@ -46,9 +46,9 @@ module.exports = () => describe('Decrypt and decompress message tests', function
|
||||||
it(`Decrypts message compressed with ${key}`, async function () {
|
it(`Decrypts message compressed with ${key}`, async function () {
|
||||||
const message = await openpgp.message.readArmored(test.input);
|
const message = await openpgp.message.readArmored(test.input);
|
||||||
const options = {
|
const options = {
|
||||||
passwords: password,
|
passwords: password,
|
||||||
message
|
message
|
||||||
};
|
};
|
||||||
return openpgp.decrypt(options).then(function (decrypted) {
|
return openpgp.decrypt(options).then(function (decrypted) {
|
||||||
expect(decrypted.data).to.equal(test.output + '\n');
|
expect(decrypted.data).to.equal(test.output + '\n');
|
||||||
});
|
});
|
||||||
|
|
1252
test/general/key.js
1252
test/general/key.js
File diff suppressed because it is too large
Load Diff
|
@ -33,7 +33,7 @@ describe('Unit Tests', function () {
|
||||||
openpgp.config[key] = decodeURIComponent(value);
|
openpgp.config[key] = decodeURIComponent(value);
|
||||||
try {
|
try {
|
||||||
openpgp.config[key] = window.eval(openpgp.config[key]);
|
openpgp.config[key] = window.eval(openpgp.config[key]);
|
||||||
} catch(e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user