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

Dropped support for Node <16 #29

Open
TLeszczynskiWA opened this issue Aug 18, 2023 · 0 comments
Open

Dropped support for Node <16 #29

TLeszczynskiWA opened this issue Aug 18, 2023 · 0 comments

Comments

@TLeszczynskiWA
Copy link

TLeszczynskiWA commented Aug 18, 2023

Hey,
I've noticed that the newest version (1.4.1) doesn't work on pre-16 Node versions. That's the error:

TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type string or an instance of Buffer, TypedArray, DataView, or KeyObject. Received an instance of ArrayBuffer
    at new NodeError (internal/errors.js:322:7)
    at prepareSecretKey (internal/crypto/keys.js:322:11)
    at new Hmac (internal/crypto/hash.js:111:9)
    at Object.createHmac (crypto.js:146:10)
    at zCe (/var/task/index.js:104:39810)
    at Object.Vlt [as createLMv2Response] (/var/task/index.js:104:39953)
    at Object.Klt (/var/task/index.js:104:43424)
    at /var/task/index.js:104:48437
    at p (/var/task/index.js:104:47086)
    at Object.next (/var/task/index.js:104:46369)

I've decided to dig a little and I think I know why it happens now. Basically, js-md4 buffer method (which has been deprecated btw) that is used to create a hash used as a key for HMAC returns an ArrayBuffer. The thing is - ArrayBuffer support in crypto's createHmac has been added in Node v16.

Create a hash and pass it to createLMv2Response
Util used for hash generation - uses js-md4 buffer that returns ArrayBuffer
MD4 hash passed down
The ArrayBuffer hash being passed to crypto.createHmac and breaking pre-16 Node versions

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