Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #12

Merged
merged 4 commits into from Mar 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 12 additions & 6 deletions README.md
Expand Up @@ -15,13 +15,19 @@
'0x33838c6f4e621982c2009f9b93ecb854a4b122538159623abc87d2e4c5bd6d2e33591f443b419b3bd2790e455ba6d625f2ca14b822c5cef824ef7e9021443bed1c';
const address = '0x86aa354fc865925f945b803ceae0b3f9d856b269';

const isSignerActionableOnAddress = await dappAuth.isSignerActionableOnAddress(
challenge,
signature,
address,
);
try {
const isAuthorizedSigner = await dappAuth.isAuthorizedSigner(
challenge,
signature,
address,
);

console.log(isAuthorizedSigner); // true
}
} catch (e) {
console.log(e);
}

console.log(isSignerActionableOnAddress); // true
}
```

19 changes: 9 additions & 10 deletions index.js
Expand Up @@ -31,17 +31,16 @@ module.exports = class DappAuth {
isAuthorizedDirectKey = true;
}
} catch (e) {
// if either direct-keyed auth flow threw an error, or it did not conclude to be authorized, proceed to try smart-contract wallet in finally clause.
} finally {
if (isAuthorizedDirectKey === true) return isAuthorizedDirectKey;
// try smart-contract wallet
const erc1271CoreContract = new this.web3.eth.Contract(ERC1271, address);
// if either direct-keyed auth flow threw an error, or it did not conclude to be authorized, proceed to try smart-contract wallet.
}
if (isAuthorizedDirectKey === true) return isAuthorizedDirectKey;
// try smart-contract wallet
const erc1271CoreContract = new this.web3.eth.Contract(ERC1271, address);

const magicValue = await erc1271CoreContract.methods
.isValidSignature(ethUtil.keccak(challenge), signature) // we send just a regular hash, which then the smart contract hashes ontop to an erc191 hash
.call();
const magicValue = await erc1271CoreContract.methods
.isValidSignature(ethUtil.keccak(challenge), signature) // we send just a regular hash, which then the smart contract hashes ontop to an erc191 hash
.call();

return magicValue === ERC1271_MAGIC_VALUE;
}
return magicValue === ERC1271_MAGIC_VALUE;
}
};
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@dapperlabs/dappauth",
"version": "2.0.1",
"version": "2.0.2",
"description": "A util to prove actionable control ('ownership') over a public Ethereum address using eth_sign",
"keywords": [
"ethereum",
Expand Down