algorand / algorand/js-algorand-sdk
Stop using `Buffer` in browser code
- Lingua principale
- TypeScript
- Stelle
- 297
- Fork
- 214
- Merge medio
- 1h 3m
- PR unite (30g)
- 3
Descrizione
## Summary
We use the npm [buffer](https://www.npmjs.com/package/buffer) package to allow our library to use node's `Buffer` class in the browser.
I think we should stop doing this for a few reasons:
* [buffer](https://www.npmjs.com/package/buffer) does not appear to be maintained anymore, as it hasn't been updated in ~2 years and has numerous issue and PRs open.
* Webpack v4 projects provide an even older version of [buffer](https://www.npmjs.com/package/buffer), and we're unable to do anything about it. This is pretty concerning, as we don't test with this older version.
* Most of our `Buffer` usage seems to be encoding and decoding base64. We should be able to do this in the browser without `Buffer`.
## Suggestions
Instead of relying on a browser `Buffer` implementation, we could make better use of `Uint8Array` and `Dataview`, which are supported in both node and browser. Some things will still require `Buffer` usage in node (like base64 encoding), but we can investigate ways to have an alternative code path for browsers.
There are a few public APIs which reference `Buffer`, so changing these would likely have to wait for a major release of the library.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.