thunderclient / thunder-client-support

Thunder Client is a lightweight Rest API Client Extension for VS Code.
https://www.thunderclient.com
Other
3.62k stars 127 forks source link

Error in Pre Request Script: - unexpected type, use Uint8Array #1434

Closed DnlCYan closed 5 months ago

DnlCYan commented 9 months ago

Describe the bug I'm running a pre request script to sign a message. For that I'm loading tweetnacl external module and when I try to create a KeyPair from a seed I encounter the following error: unexpected type, use Uint8Array

I can confirm that the variable is an instanceof Uint8Array (first console.log)

I can successfully run a similar code on an online nodejs compiler https://onecompiler.com/nodejs/3zvmv9jsy

I know external module loading is still Beta. But there should be an issue and it would be great to have a fix on it.

To Reproduce

Expected behavior This should be the output on the console: true 0e21765c4bf20def6267b742583b9197c91cd1eb6131419c1d2cb91d42b3eb4baaa35c1a29fddd87ae3d6f7f31091115152385b745c07067eef00bbe5a917106

Platform:

Are you using the free version/paid version/trial: free version

rangav commented 9 months ago

Hi @DnlCYan

The node libraries are loaded successfully I think.

The error is occuring in this line - const signingKey2 = nacl.sign.keyPair.fromSeed(signingKeySeed);;

reference - https://github.com/dchest/tweetnacl-js/issues/148

DnlCYan commented 9 months ago

Hi @DnlCYan

The node libraries are loaded successfully I think.

The error is occuring in this line - const signingKey2 = nacl.sign.keyPair.fromSeed(signingKeySeed);;

reference - dchest/tweetnacl-js#148

Hi @rangav

Yes, I know where it comes from. And on the line before I check if signingKeySeed is instanceof Uint8Array, which is true. So from tweetnacl code, we shouldn't get this error.

And I run this code on onecompiler.com without this error. That's why I was wondering if there's any issue loading the lib.

And the reference you indicate is not the same because he checks if it is instanceof Uint8Array and it gets false. In my case I get true.

DnlCYan commented 9 months ago

can we know which versions Thunder uses for:

rangav commented 9 months ago

Node 16 or above, I don't know about the buffer

rangav commented 5 months ago

We have improved the loading of Node modules in the new update. Please update to v2.20.0.

You can see all the features released in this update https://github.com/rangav/thunder-client-support/releases/tag/v2.20.0

Please test it and let me know your feedback