-
Notifications
You must be signed in to change notification settings - Fork 320
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
Added webAuthDomain parameter and validation to SEP-10 util functions #607
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[tragically trying to undo an approval]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JS looks good & comprehensive. I can't speak to the validity of the implementation (largely unfamiliar with SEP-10) so wait on @leighmcculloch for that, but otherwise this LGTM 👍. Thanks for doing this after raising #606, Jake!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One change in this PR conflicts ( ⏩ ) with another open PR and we should address that in that other PR I think, and there's one critical change ( ❗ ) I think we should make before merging this, otherwise looks great.
Love the tests 🎉 .
I had to force push after rebasing this branch on the update master, sorry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Looks great. Nice fix on the buffer compare. One suggestion (💡).
} | ||
if ( | ||
op.name === "web_auth_domain" && | ||
op.value.compare(Buffer.from(webAuthDomain)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it. 🚀
Initially I wasn't sure if this would work because compare
returns a -1
, 0
, or 1
depending how the two buffers sort, but TIL it does work because:
> !!-1
true
> !!1
true
> !!0
false
test/unit/utils_test.js
Outdated
"testanchor.stellar.org", | ||
"testanchor.stellar.org" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 For the sake of making sure the correct parameter is being matched against could you make the home domain an web auth domain different?
@@ -234,6 +245,19 @@ export namespace Utils { | |||
"The transaction has operations that are unrecognized", | |||
); | |||
} | |||
if (op.value === undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @leighmcculloch @JakeUrban, I have some confusion about this, does the SEP-10 protocol specify that the values in other ManageData Operation cannot be null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point, it does not specify this and shouldn't reject a challenge transaction because of this. This is a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch. I'll fix it today, before release.
resolves #606
Changes:
webAuthDomain
parameter toreadChallengeTx()
,buildChallengeTx()
,verifyChallengeTxSigners()
, andverifyChallengeTxThreshold()
buildChallengeTx()
now adds an additional Manage Data operation as described in the SEP-10 v3.1 changesreadChallengeTx()
now verifies that the addedwebAuthDomain
parameter matches the added Manage Data operation value if included in the challengeverifyChallengeTxSigners()
andverifyChallengeTxThreshold()
passwebAuthDomain
toreadChallengeTx()
untils_test.js
) have been added & updated