Open tiagoj opened 1 year ago
This also happens on Windows 11.
const password = 'mypassword';
const hash = await argon2.hash(
password,
{
type: argon2.argon2id,
}
);
If I remove type: argon2.argon2id,
option, it runs fine.
@ve3 what version of the library are you using? It was solved in the past and now it passes function name to @phc/format
It is newly installed.
"argon2": "^0.30.3"
Node 18.12.1
I can reproduce it on Node.JS v18.10.0 and "argon2": "^0.30.3"
.
if set type with number, it runs fine
const hash = await argon2.hash('password', {
type: argon2.argon2d // error
})
const hash2 = await argon2.hash('password', {
type: 0 // success
})
This is not a show stopper for me, but I thought I would mention it.
Steps to reproduce
"argon2": "^0.29.1"
I'm using this code segment in Typescript
Note: That because the 'type' I was using is the default anyway, just deleting the 'type' line avoids the bug.
You don't really need to reproduce the issue, just looking at the source shows the mismatch.
Expected behaviour
Typescript declared types should agree with internal dynamic check.
Actual behaviour
If I set id to an integer as required by the typescript type, it results in a runtime error when the type check fails in the serialize() function in index.js
If I set it to a string, the Typescipt compiler issues an error TypeError: id must be a string at serialize (/Users/james/GitRepos/WebMisc/RmaSite/dev/dbApi/node_modules/@phc/format/index.js:59:11) at Module.hash (/Users/james/GitRepos/WebMisc/RmaSite/dev/dbApi/node_modules/argon2/argon2.js:68:10) ...
The odd thing, is that even with the error, using commonJs modules, it seemed to work, but when switching to use EJS (for other reasons), it started catching the error.
Environment
MAC
node: v16.13.0
typescript: Version 4.7.4