Permalink
Browse files

Use isHash instead of checking for presence of optional salt

  • Loading branch information...
1 parent d9f4060 commit 87dec93e0a707df8b370ac33e895d540f9e3a3cc @stenington stenington committed Dec 18, 2013
Showing with 5 additions and 1 deletion.
  1. +1 −1 index.js
  2. +4 −0 test/validator-utils.test.js
View
@@ -42,7 +42,7 @@ function doesHashedEmailMatch(hashedEmail, salt, email) {
function doesRecipientMatch(info, identity) {
var assertion = info.structures.assertion;
if (info.version == "0.5.0") {
- if (typeof(assertion.salt) == "string")
+ if (isHash(assertion.recipient))
return doesHashedEmailMatch(assertion.recipient, assertion.salt,
identity);
else
@@ -57,6 +57,10 @@ test('validator.doesRecipientMatch works w/ 0.5.0 assertions', function(t) {
recipient: 'sha256$' + validator.sha256('foo@example.org' + 'lol')
}), 'bar@example.org'), false, "works w/ unmatching hashed identities");
+ t.equal(validator.doesRecipientMatch(mkInfo({
+ recipient: 'sha256$' + validator.sha256('foo@example.org')
+ }), 'foo@example.org'), true, "works w/ matching unsalted hashed identities");
+
t.equal(validator.doesRecipientMatch(mkInfo({
recipient: 'foo@example.org'
}), 'foo@example.org'), true, "works w/ matching unhashed identities");

0 comments on commit 87dec93

Please sign in to comment.