merge staging and do a little lint compliance

This commit is contained in:
ansuz
2020-02-17 11:54:27 -05:00
parent f478ae725d
commit a4be6185de
4 changed files with 51 additions and 9 deletions

View File

@@ -21,16 +21,49 @@ var isValidOwner = function (owner) {
// ["RESTRICT_ACCESS", [true], 1561623438989]
// ["RESTRICT_ACCESS", [false], 1561623438989]
// commands.RESTRICT_ACCESS = function (meta, args) {};
commands.RESTRICT_ACCESS = function (meta, args) {
if (!Array.isArray(args) || typeof(args[0]) !== 'boolean') {
throw new Error('INVALID_STATE');
}
var bool = args[0];
// reject the proposed command if there is no change in state
if (meta.restricted === bool) { return false; }
// apply the new state
meta.restricted = args[0];
// if you're disabling access restrictions then you can assume
// then there is nothing more to do. Leave the existing list as-is
if (!bool) { return true; }
// you're all set if an allow list already exists
if (Array.isArray(meta.allowed)) { return true; }
// otherwise define it
meta.allowed = [];
return true;
};
// ["ADD_ALLOWED", ["7eEqelGso3EBr5jHlei6av4r9w2B9XZiGGwA1EgZ-5I=", ...], 1561623438989]
// commands.ADD_ALLOWED = function (meta, args) {};
commands.ADD_ALLOWED = function (meta, args) {
args = args;
throw new Error('NOT_IMPLEMENTED');
};
// ["RM_ALLOWED", ["7eEqelGso3EBr5jHlei6av4r9w2B9XZiGGwA1EgZ-5I=", ...], 1561623438989]
// commands.RM_ALLOWED = function (meta, args) {};
commands.RM_ALLOWED = function (meta, args) {
args = args;
throw new Error('NOT_IMPLEMENTED');
};
// ["RESET_ALLOWED", ["7eEqelGso3EBr5jHlei6av4r9w2B9XZiGGwA1EgZ-5I=", ...], 1561623438989]
// commands.RESET_ALLOWED = function (meta, args) {};
commands.RESET_ALLOWED = function (meta, args) {
args = args;
throw new Error('NOT_IMPLEMENTED');
};
// ["ADD_OWNERS", ["7eEqelGso3EBr5jHlei6av4r9w2B9XZiGGwA1EgZ-5I="], 1561623438989]
commands.ADD_OWNERS = function (meta, args) {