Skip to content

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

@enspritz

Description

@enspritz

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
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions