WietseWind / xrpl-accountlib

XRPL Account helper: generation, derivation and signing (family seed, mnemonic, passphrase)
MIT License
26 stars 12 forks source link

Use of account lib, DeprecationWarning: Buffer() is deprecated #308

Closed shortthefomo closed 1 year ago

shortthefomo commented 1 year ago

Using this lib with evernode im getting the following warning.

im guessing this is due to the trans compilation.

DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead

WietseWind commented 1 year ago

Can you see which submodule (file path) triggers it?

shortthefomo commented 1 year ago

not sure how to find that but as soon as i add const lib = require('xrpl-accountlib') im getting that warning.

Screen Shot 2022-10-17 at 17 12 27

I tried adding --trace-deprecation to the scripts in the package but that then complains that it does not know what param that is.

Screen Shot 2022-10-17 at 17 14 56

npx ncc build is doing the trans compile there.

WietseWind commented 1 year ago

I checked the source of the lib. and I can't find the use of Buffer as a constructor;

generate/familySeed.ts:  entropy?: Buffer | Uint8Array;
utils/index.ts:function bufferToHext(buffer: Buffer): string {
utils/index.ts:  return Buffer.from(nonCanonicalDer).toString("hex").toUpperCase();

What kind of secret type (mnemonic, family seed, ... ) are you using when you get this error?

shortthefomo commented 1 year ago

thats the thing, i dont even need to have accountSetup(ctx) and it throws the warning as soon as i add const lib = require('xrpl-accountlib')don't even use it just declare it the warning is printed from the contract.

Screen Shot 2022-10-17 at 21 47 46
shortthefomo commented 1 year ago

figured out this is part of Evernodes issue after being able to dump the stack trace.

shortthefomo commented 1 year ago

FYI, Found the source of this one @WietseWind its the secret libs codec thats used.

WietseWind commented 1 year ago

Thanks, that's some nice digging!

Created a PR: https://github.com/professorhantzen/ripple-secret-codec/pull/2

If merged & published to npm: great, otherwise I'll incorporate the updated version in xrpl-accountlib soon.

WietseWind commented 1 year ago

Merged :) Updated ripple-secret-codec@1.0.3 is now included in the just published xrpl-accountlib@1.5.3 :)