Restrict addition of signatures

Sending an email to the primary userID to select which signatures to add when new signatures are uploaded.
This commit is contained in:
Simon Vareille
2020-02-10 18:10:10 +01:00
parent d0083a4f57
commit 5a05cecdb8
6 changed files with 135 additions and 17 deletions

View File

@@ -36,7 +36,29 @@ exports.isString = function(data) {
exports.isTrue = function(data) {
if (this.isString(data)) {
return data === 'true';
} else {
} else /**
* Check Uint8Array equality
* @param {Uint8Array} first array
* @param {Uint8Array} second array
* @returns {Boolean} equality
*/
equalsUint8Array: function (array1, array2) {
if (!util.isUint8Array(array1) || !util.isUint8Array(array2)) {
throw new Error('Data must be in the form of a Uint8Array');
}
if (array1.length !== array2.length) {
return false;
}
for (let i = 0; i < array1.length; i++) {
if (array1[i] !== array2[i]) {
return false;
}
}
return true;
},
{
return Boolean(data);
}
};
@@ -103,6 +125,28 @@ exports.normalizeEmail = function(email) {
return email;
};
/**
* Check Uint8Array equality
* @param {Uint8Array} first array
* @param {Uint8Array} second array
* @returns {Boolean} equality
*/
exports.equalsUint8Array: function (array1, array2) {
try {
if (array1.length !== array2.length) {
return false;
}
for (let i = 0; i < array1.length; i++) {
if (array1[i] !== array2[i]) {
return false;
}
}
} catch (e) {return false;}
return true;
};
/**
* Create an error with a custom status attribute e.g. for http codes.
* @param {number} status The error's http status code