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

Replace Buffer with Uint8Array #1883

Open
dawsbot opened this issue Apr 7, 2024 · 2 comments
Open

Replace Buffer with Uint8Array #1883

dawsbot opened this issue Apr 7, 2024 · 2 comments
Labels
s-triage Needs to be reviewed, designed and prioritized

Comments

@dawsbot
Copy link
Contributor

dawsbot commented Apr 7, 2024

What is the bug?
This is a question about a potential bug!

All instances of JS Buffer could be replaced with Uint8Array. Why would we want to?

TLDR:

  1. Buffer does not work cross-platform
  2. Buffer modifies a global object which can be accessed by third-party dependencies
  3. slice mutates the original object

Additional context (optional)
This is a question and discussion beginning. Please leave feedback! If you want to learn more about why this matters, read here: https://sindresorhus.com/blog/goodbye-nodejs-buffer

@github-actions github-actions bot added the s-triage Needs to be reviewed, designed and prioritized label Apr 7, 2024
@dawsbot
Copy link
Contributor Author

dawsbot commented Apr 13, 2024

@paulmillr you may have some expertise or recommendations on this topic 🙏

@paulmillr
Copy link

It’s pretty easy. Just replace everything with Uint8Array.from(buffer) at first. then, replace Buffer creation with Uint8Array creation.

If you use Buffer.prototype.toString (“hex”), replace it with bytesToHex from noble hashes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s-triage Needs to be reviewed, designed and prioritized
Projects
None yet
Development

No branches or pull requests

2 participants