Skip to content

Commit

Permalink
Allow non-active/owner keys during initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
aaroncox committed Mar 3, 2019
1 parent f8e39ac commit 1d38dff
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions app/shared/actions/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,18 @@ export function validateKey(key) {
account = eos(connection).getAccount(settings.account);
}
// Keys must resolve to one of these types of permissions
const permissions = ['active', 'owner'];
try {
// Derive the public key from the private key provided
const expect = ecc.privateToPublic(key, connection.keyPrefix);
// Filter the account's permissions to find any valid matches
const validPermissions = account.permissions.filter((perm) => {
// Get the threshold a key needs to perform operations
const { threshold } = perm.required_auth;
// ensure the proper type of permission is provided by the auth
if (permissions.indexOf(perm.perm_name) !== -1) {
// finally determine if any keys match
const matches = perm.required_auth.keys.filter((auth) =>
(auth.key === expect) && (auth.weight >= threshold));
// this is a valid permission should any of the keys and thresholds match
return (matches.length > 0);
}
return false;
// finally determine if any keys match
const matches = perm.required_auth.keys.filter((auth) =>
(auth.key === expect) && (auth.weight >= threshold));
// this is a valid permission should any of the keys and thresholds match
return (matches.length > 0);
});
// If the key matches any valid permission it's good
if (validPermissions.length > 0) {
Expand Down

0 comments on commit 1d38dff

Please sign in to comment.