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

argon2.verify() documentation in README.md is wrong #95

Open
enspritz opened this issue Nov 23, 2023 · 1 comment
Open

argon2.verify() documentation in README.md is wrong #95

enspritz opened this issue Nov 23, 2023 · 1 comment

Comments

@enspritz
Copy link

README.md says:

argon2.verify({
    // <CODE ELIDED>
})
// result
.then(res => {
    res.hash // hash as Uint8Array
    res.hashHex // hash as hex-string
    res.encoded // encoded hash, as required by argon2
})
// or error
.catch(err => {
    err.message // error message as string, if available
    err.code // numeric error code
})

Which is desirable! I need res.hash after a successful verification. But, meanwhile, back in argon2.js:

  let result;
  if (res || err) {
    // <CODE ELIDED>
    result = { message: err, code: res };
  }
  // <CODE ELIDED>
  if (err) {
    throw result;
  } else {
    return result;
  }

.. returning undefined in the case of success. And indeed argon2_library.c indicates we can only receive a status code and not the various hash values:

  ret = argon2_verify_ctx(&ctx, (char *)desired_result, type);

SO, the res data structure containing encoded, hash, hashHex needs to be re-written out of the README.md sample .then() clause , perhaps like this:

argon2.verify({
    // <CODE ELIDED>
})
// success
then(() => console.log("success!"))
// or error
.catch(err => {
    err.message // error message as string, if available
    err.code // numeric error code
})
@enspritz
Copy link
Author

See also #7 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant